From 4060f83261e55a8fe2baa0bbdd3b3adae8f39b73 Mon Sep 17 00:00:00 2001 From: Marcus Hert da Coregio Date: Tue, 1 Jun 2021 14:00:25 -0300 Subject: [PATCH] Add a link checker to docs build Closes gh-9818 --- buildSrc/build.gradle | 1 + .../gradle/convention/DocsPlugin.groovy | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index b75e9291a9..604cfd11a0 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -80,6 +80,7 @@ dependencies { implementation 'io.spring.gradle:propdeps-plugin:0.0.10.RELEASE' implementation 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.15' implementation 'io.spring.nohttp:nohttp-gradle:0.0.8' + implementation 'org.aim42:htmlSanityCheck:1.1.6' implementation 'org.asciidoctor:asciidoctor-gradle-jvm:3.1.0' implementation 'org.asciidoctor:asciidoctor-gradle-jvm-pdf:3.1.0' implementation 'org.hidetake:gradle-ssh-plugin:2.10.1' diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy index 40c29998cb..a527d719e6 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy @@ -1,14 +1,13 @@ package io.spring.gradle.convention +import org.aim42.htmlsanitycheck.HtmlSanityCheckPlugin +import org.aim42.htmlsanitycheck.HtmlSanityCheckTask +import org.aim42.htmlsanitycheck.check.BrokenHttpLinksChecker import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask -import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task -import org.gradle.api.artifacts.Configuration -import org.gradle.api.artifacts.DependencySet import org.gradle.api.plugins.PluginManager -import org.gradle.api.tasks.Sync import org.gradle.api.tasks.bundling.Zip /** @@ -25,6 +24,7 @@ public class DocsPlugin implements Plugin { pluginManager.apply(AsciidoctorConventionPlugin); pluginManager.apply(DeployDocsPlugin); pluginManager.apply(JavadocApiPlugin); + pluginManager.apply(HtmlSanityCheckPlugin) String projectName = Utils.getProjectName(project); String pdfFilename = projectName + "-reference.pdf"; @@ -38,6 +38,17 @@ public class DocsPlugin implements Plugin { } } + project.tasks.withType(HtmlSanityCheckTask) { HtmlSanityCheckTask t -> + project.configure(t) { + t.dependsOn 'asciidoctor' + t.checkerClasses = [BrokenHttpLinksChecker] + t.checkingResultsDir = new File(project.getBuildDir(), "/report/htmlchecks") + t.failOnErrors = false + t.httpConnectionTimeout = 3000 + t.sourceDir = new File(project.getBuildDir(), "/docs/asciidoc/") + t.sourceDocuments = project.files(new File(project.getBuildDir(), "/docs/asciidoc/index.html")) + } + } Task docsZip = project.tasks.create('docsZip', Zip) { dependsOn 'api', 'asciidoctor'