Skip to content

Commit 9486ece

Browse files
committed
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. In addition, the asciidoctor task now has a dynamic dependency on the asciidoctorPdf task if the current project version is a non-SNAPSHOT version. Thus, invoking `./gradlew asciidoctor` will still generate both the HTML5 and PDF outputs for non-SNAPSHOT versions; whereas, `./gradlew asciidoctorPdf` will generate only the PDF outputs regardless of the current project version. See gh-25783
1 parent 560fec5 commit 9486ece

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

gradle/docs.gradle

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,18 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
17+
import org.asciidoctor.gradle.AsciidoctorTask
18+
19+
buildscript {
20+
repositories {
21+
maven { url "https://repo.spring.io/plugins-release" }
22+
}
23+
dependencies {
24+
classpath("org.asciidoctor:asciidoctor-gradle-plugin:1.5.8")
25+
classpath("org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16")
26+
}
27+
}
1628

1729
task api(type: Javadoc) {
1830
group = "Documentation"
@@ -80,7 +92,15 @@ dokka {
8092
}
8193
}
8294

95+
asciidoctorj {
96+
version = '1.5.8'
97+
}
98+
8399
asciidoctor {
100+
// only output PDF documentation for non-SNAPSHOT builds
101+
if (!project.getVersion().toString().contains("BUILD-SNAPSHOT")) {
102+
dependsOn 'asciidoctorPdf'
103+
}
84104
sources {
85105
include '*.adoc'
86106
}
@@ -91,10 +111,6 @@ asciidoctor {
91111
}
92112
logDocuments = true
93113
backends = ["html5"]
94-
// only ouput PDF documentation for non-SNAPSHOT builds
95-
if(!project.getVersion().toString().contains("BUILD-SNAPSHOT")) {
96-
backends += "pdf"
97-
}
98114
options doctype: 'book', eruby: 'erubis'
99115
attributes 'icons': 'font',
100116
'idprefix': '',
@@ -107,7 +123,29 @@ asciidoctor {
107123
stylesdir: 'stylesheets/',
108124
stylesheet: 'main.css',
109125
'spring-version': project.version
126+
}
110127

128+
task asciidoctorPdf(type: AsciidoctorTask) {
129+
sources {
130+
include '*.adoc'
131+
}
132+
logDocuments = true
133+
backends = ["pdf"]
134+
options doctype: 'book', eruby: 'erubis'
135+
attributes 'icons': 'font',
136+
'idprefix': '',
137+
'idseparator': '-',
138+
docinfo: '',
139+
revnumber: project.version,
140+
sectanchors: '',
141+
sectnums: '',
142+
'source-highlighter': 'coderay@', // TODO switch to 'rouge' once supported by the html5 backend
143+
stylesdir: 'stylesheets/',
144+
stylesheet: 'main.css',
145+
'spring-version': project.version
146+
doLast {
147+
project.delete("$asciidoctorPdf.outputDir/pdf/images")
148+
}
111149
}
112150

113151
task docsZip(type: Zip, dependsOn: ['api', 'asciidoctor', 'dokka']) {

0 commit comments

Comments
 (0)