From 4179ea6f22cbf216a08238a028181e31fde4ffe7 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 18 Sep 2020 17:58:25 +0200 Subject: [PATCH] Remove unnecessary folders and files from PDF reference documentation Prior to this commit, the asciidoctor Gradle task was configured to generate both the HTML5 and PDF backends. Unfortunately, this resulted in resources such as HTML, JavaScript, CSS, and images being published alongside the generated PDF documents. This commit addresses this issue by introducing the use of a dedicated asciidoctorPdf Gradle task. The existing asciidoctor Gradle task has been modified to only generate HTML5 output. Both of these tasks now share common configuration supplied by the updated asciidoctorj Gradle task. In addition, the asciidoctor task now depends on the asciidoctorPdf task. Thus, invoking `./gradlew asciidoctor` will still generate both the HTML5 and PDF outputs; whereas, `./gradlew asciidoctorPdf` will generate only the PDF outputs. We may later decide to rework the tasks to introduce a dedicated asciidoctorHtml task so that we can generate the HTML outputs without having to generate the PDF outputs (which are more time consuming). See gh-25783 --- build.gradle | 1 + gradle/docs.gradle | 56 ++++++++++++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/build.gradle b/build.gradle index c1533a2b697..e2cbd19359c 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ plugins { id 'org.jetbrains.kotlin.jvm' version '1.4.10' apply false id 'org.jetbrains.dokka' version '0.10.1' apply false id 'org.asciidoctor.jvm.convert' version '2.4.0' + id 'org.asciidoctor.jvm.pdf' version '2.4.0' id 'de.undercouch.download' version '4.1.1' id "io.freefair.aspectj" version '5.1.1' apply false id "com.github.ben-manes.versions" version '0.28.0' diff --git a/gradle/docs.gradle b/gradle/docs.gradle index ae698420133..24d994004f4 100644 --- a/gradle/docs.gradle +++ b/gradle/docs.gradle @@ -130,45 +130,57 @@ asciidoctorj { } } fatalWarnings ".*" + options doctype: 'book', eruby: 'erubis' + attributes([ + icons: 'font', + idprefix: '', + idseparator: '-', + docinfo: 'shared', + revnumber: project.version, + sectanchors: '', + sectnums: '', + 'source-highlighter': 'highlight.js', + highlightjsdir: 'js/highlight', + 'highlightjs-theme': 'googlecode', + stylesdir: 'css/', + stylesheet: 'stylesheet.css', + 'spring-version': project.version + ]) } /** - * Produce the Spring Framework Reference documentation - * from "src/docs/asciidoc" into "build/asciidoc/html5" + * Generate the Spring Framework Reference documentation from "src/docs/asciidoc" + * in "build/docs/ref-docs/html5". */ asciidoctor { + dependsOn asciidoctorPdf baseDirFollowsSourceDir() configurations 'asciidoctorExt' sources { include '*.adoc' } - outputDir "$buildDir/docs/ref-docs/" + outputDir "$buildDir/docs/ref-docs/html5" + logDocuments = true resources { from(sourceDir) { include 'images/*.png', 'css/**', 'js/**' } from extractDocResources } - logDocuments = true - outputOptions { - backends = ["html5", "pdf"] +} + +/** + * Generate the Spring Framework Reference documentation from "src/docs/asciidoc" + * in "build/docs/ref-docs/pdf". + */ +asciidoctorPdf { + baseDirFollowsSourceDir() + configurations 'asciidoctorExt' + sources { + include '*.adoc' } - options doctype: 'book', eruby: 'erubis' - attributes([ - icons: 'font', - idprefix: '', - idseparator: '-', - docinfo: 'shared', - revnumber: project.version, - sectanchors: '', - sectnums: '', - 'source-highlighter': 'highlight.js', - highlightjsdir: 'js/highlight', - 'highlightjs-theme': 'googlecode', - stylesdir: 'css/', - stylesheet: 'stylesheet.css', - 'spring-version': project.version - ]) + outputDir "$buildDir/docs/ref-docs/pdf" + logDocuments = true } /**