Skip to content

Commit 924adae

Browse files
committed
Render reference documentation with Asciidoctor
This commit removes docbook from the documentation toolchain and instead makes use of asciidoctor to render the reference documentation in HTML and PDF formats. The main Gradle build has been refactored with the documentation tasks and sniffer tasks extracted to their own gradle file in the "gradle" folder. A new asciidoctor Spring theme is also used to render the HTML5 backend. Issue: SPR-14997
1 parent c5bcefb commit 924adae

File tree

93 files changed

+1030
-311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1030
-311
lines changed

build.gradle

+5-236
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ buildscript {
66
classpath("io.spring.gradle:dependency-management-plugin:1.0.0.RELEASE")
77
classpath("io.spring.gradle:propdeps-plugin:0.0.8")
88
classpath("io.spring.gradle:docbook-reference-plugin:0.3.1")
9-
classpath("org.asciidoctor:asciidoctor-gradle-plugin:1.5.3")
109
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.1")
10+
classpath("org.asciidoctor:asciidoctor-gradle-plugin:1.5.3")
11+
classpath("org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.14")
12+
classpath("org.asciidoctor:asciidoctorj-epub3:1.5.0-alpha.6")
1113
}
1214
}
1315

@@ -86,7 +88,6 @@ configure(allprojects) { project ->
8688
ext.servletVersion = "3.1.0"
8789
ext.slf4jVersion = "1.7.25"
8890
ext.snakeyamlVersion = "1.18"
89-
ext.snifferVersion = "1.15"
9091
ext.testngVersion = "6.11"
9192
ext.tiles3Version = "3.0.7"
9293
ext.tomcatVersion = "8.5.12"
@@ -104,6 +105,7 @@ configure(allprojects) { project ->
104105
apply plugin: "java"
105106
apply plugin: "test-source-set-dependencies"
106107
apply from: "${gradleScriptDir}/ide.gradle"
108+
apply from: "${gradleScriptDir}/sniffer.gradle"
107109

108110
// Kotlin compiler does not support JDK 9 yet, see https://youtrack.jetbrains.com/issue/KT-14988
109111
if (!JavaVersion.current().java9Compatible) {
@@ -119,11 +121,6 @@ configure(allprojects) { project ->
119121
}
120122
}
121123

122-
configurations {
123-
sniffer
124-
javaApiSignature
125-
}
126-
127124
configurations.all {
128125
// Check for updates every build
129126
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
@@ -192,44 +189,6 @@ configure(allprojects) { project ->
192189
testCompile("org.hamcrest:hamcrest-all:${hamcrestVersion}")
193190
testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
194191
testRuntime("org.apache.logging.log4j:log4j-jcl:${log4jVersion}")
195-
196-
sniffer("org.codehaus.mojo:animal-sniffer-ant-tasks:${snifferVersion}")
197-
javaApiSignature("org.codehaus.mojo.signature:java18:1.0@signature")
198-
}
199-
200-
task copyJavaApiSignature(type: Copy) {
201-
ext.to = file("$buildDir/javaApiSignature/")
202-
description "Copy the resolved Animal Sniffer signature dependency artifact to a known location and name"
203-
from configurations.javaApiSignature
204-
into to
205-
rename '.*signature', 'javaApi.signature'
206-
}
207-
208-
task sniff {
209-
group = "Verification"
210-
description = "Checks the Java API signatures"
211-
212-
dependsOn compileJava
213-
dependsOn copyJavaApiSignature
214-
215-
inputs.dir sourceSets.main.output.classesDir
216-
inputs.dir copyJavaApiSignature.to
217-
218-
doLast {
219-
ant.taskdef(
220-
name: 'animalSniffer',
221-
classname: 'org.codehaus.mojo.animal_sniffer.ant.CheckSignatureTask',
222-
classpath: configurations.sniffer.asPath
223-
)
224-
225-
// TODO: Animal Sniffer currently chokes on optional JDK 9 bytecode in AspectJ 1.9 beta 5
226-
// ant.animalSniffer(
227-
// signature: "$buildDir/javaApiSignature/javaApi.signature",
228-
// classpath: sourceSets.main.compileClasspath.asPath) {
229-
// path(path: sourceSets.main.output.classesDir)
230-
// annotation(className: "org.springframework.lang.UsesSunHttpServer")
231-
// }
232-
}
233192
}
234193

235194
ext.javadocLinks = [
@@ -1240,13 +1199,11 @@ sonarqube {
12401199
configure(rootProject) {
12411200
description = "Spring Framework"
12421201

1243-
apply plugin: "org.asciidoctor.convert"
1244-
apply plugin: "docbook-reference"
12451202
apply plugin: "groovy"
12461203
apply plugin: "io.spring.dependency-management"
1247-
12481204
// apply plugin: "detect-split-packages"
12491205
apply from: "${gradleScriptDir}/jdiff.gradle"
1206+
apply from: "${gradleScriptDir}/docs.gradle"
12501207

12511208
dependencyManagement {
12521209
imports {
@@ -1258,25 +1215,6 @@ configure(rootProject) {
12581215
applyMavenExclusions = false
12591216
}
12601217

1261-
asciidoctor {
1262-
sourceDir project.file('src/asciidoc')
1263-
separateOutputDirs = false
1264-
backends = ['docbook']
1265-
options doctype: 'book', eruby: 'erubis'
1266-
attributes 'spring-version': project.version, 'revnumber': project.version, 'docinfo': ""
1267-
}
1268-
1269-
reference {
1270-
sourceDir = asciidoctor.outputDir
1271-
pdfFilename = "spring-framework-reference.pdf"
1272-
epubFilename = "spring-framework-reference.epub"
1273-
expandPlaceholders = ""
1274-
}
1275-
1276-
afterEvaluate {
1277-
tasks.findAll { it.name.startsWith("reference") }.each{ it.dependsOn.add("asciidoctor") }
1278-
}
1279-
12801218
// TODO: DetectSplitPackagesPlugin fails in line 154 due to method not found on java.io.File.
12811219
// TODO: Possibly related to user rights or OS differences; passes on local Windows machine.
12821220
// detectSplitPackages {
@@ -1305,159 +1243,6 @@ configure(rootProject) {
13051243
testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
13061244
}
13071245

1308-
task api(type: Javadoc) {
1309-
group = "Documentation"
1310-
description = "Generates aggregated Javadoc API documentation."
1311-
title = "${rootProject.description} ${version} API"
1312-
1313-
dependsOn {
1314-
subprojects.collect {
1315-
it.tasks.getByName("jar")
1316-
}
1317-
}
1318-
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
1319-
options.author = true
1320-
options.header = rootProject.description
1321-
options.overview = "src/api/overview.html"
1322-
options.stylesheetFile = file("src/api/stylesheet.css")
1323-
options.splitIndex = true
1324-
options.links(project.ext.javadocLinks)
1325-
options.addStringOption('Xdoclint:none', '-quiet')
1326-
1327-
source subprojects.collect { project ->
1328-
project.sourceSets.main.allJava
1329-
}
1330-
1331-
maxMemory = "1024m"
1332-
destinationDir = new File(buildDir, "api")
1333-
1334-
doFirst {
1335-
classpath = files(
1336-
// Ensure the javadoc process can resolve types compiled from .aj sources
1337-
project(":spring-aspects").sourceSets.main.output
1338-
)
1339-
classpath += files(subprojects.collect { it.sourceSets.main.compileClasspath })
1340-
}
1341-
}
1342-
1343-
task docsZip(type: Zip, dependsOn: 'reference') {
1344-
group = "Distribution"
1345-
baseName = "spring-framework"
1346-
classifier = "docs"
1347-
description = "Builds -${classifier} archive containing api and reference " +
1348-
"for deployment at http://static.springframework.org/spring-framework/docs."
1349-
1350-
from("src/dist") {
1351-
include "changelog.txt"
1352-
}
1353-
1354-
from (api) {
1355-
into "javadoc-api"
1356-
}
1357-
1358-
from (reference) {
1359-
into "spring-framework-reference"
1360-
}
1361-
}
1362-
1363-
task schemaZip(type: Zip) {
1364-
group = "Distribution"
1365-
baseName = "spring-framework"
1366-
classifier = "schema"
1367-
description = "Builds -${classifier} archive containing all " +
1368-
"XSDs for deployment at http://springframework.org/schema."
1369-
duplicatesStrategy 'exclude'
1370-
moduleProjects.each { subproject ->
1371-
def Properties schemas = new Properties();
1372-
1373-
subproject.sourceSets.main.resources.find {
1374-
it.path.endsWith("META-INF/spring.schemas")
1375-
}?.withInputStream { schemas.load(it) }
1376-
1377-
for (def key : schemas.keySet()) {
1378-
def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1')
1379-
assert shortName != key
1380-
File xsdFile = subproject.sourceSets.main.resources.find {
1381-
it.path.endsWith(schemas.get(key))
1382-
}
1383-
assert xsdFile != null
1384-
into (shortName) {
1385-
from xsdFile.path
1386-
}
1387-
}
1388-
}
1389-
}
1390-
1391-
task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) {
1392-
group = "Distribution"
1393-
baseName = "spring-framework"
1394-
classifier = "dist"
1395-
description = "Builds -${classifier} archive, containing all jars and docs, " +
1396-
"suitable for community download page."
1397-
1398-
ext.baseDir = "${baseName}-${project.version}";
1399-
1400-
from("src/dist") {
1401-
include "readme.txt"
1402-
include "license.txt"
1403-
include "notice.txt"
1404-
into "${baseDir}"
1405-
expand(copyright: new Date().format("yyyy"), version: project.version)
1406-
}
1407-
1408-
from(zipTree(docsZip.archivePath)) {
1409-
into "${baseDir}/docs"
1410-
}
1411-
1412-
from(zipTree(schemaZip.archivePath)) {
1413-
into "${baseDir}/schema"
1414-
}
1415-
1416-
moduleProjects.each { subproject ->
1417-
into ("${baseDir}/libs") {
1418-
from subproject.jar
1419-
if (subproject.tasks.findByPath("sourcesJar")) {
1420-
from subproject.sourcesJar
1421-
}
1422-
if (subproject.tasks.findByPath("javadocJar")) {
1423-
from subproject.javadocJar
1424-
}
1425-
}
1426-
}
1427-
}
1428-
1429-
// Create a distribution that contains all dependencies (required and optional).
1430-
// Not published by default; only for use when building from source.
1431-
task depsZip(type: Zip, dependsOn: distZip) { zipTask ->
1432-
group = "Distribution"
1433-
baseName = "spring-framework"
1434-
classifier = "dist-with-deps"
1435-
description = "Builds -${classifier} archive, containing everything " +
1436-
"in the -${distZip.classifier} archive plus all runtime dependencies."
1437-
1438-
from zipTree(distZip.archivePath)
1439-
1440-
gradle.taskGraph.whenReady { taskGraph ->
1441-
if (taskGraph.hasTask(":${zipTask.name}")) {
1442-
def projectNames = rootProject.subprojects*.name
1443-
def artifacts = new HashSet()
1444-
subprojects.each { subproject ->
1445-
(subproject.configurations.runtime.resolvedConfiguration.resolvedArtifacts +
1446-
subproject.configurations.optional.resolvedConfiguration.resolvedArtifacts).each { artifact ->
1447-
def dependency = artifact.moduleVersion.id
1448-
if (!projectNames.contains(dependency.name)) {
1449-
artifacts << artifact.file
1450-
}
1451-
}
1452-
}
1453-
1454-
zipTask.from(artifacts) {
1455-
into "${distZip.baseDir}/deps"
1456-
}
1457-
}
1458-
}
1459-
}
1460-
14611246
artifacts {
14621247
archives docsZip
14631248
archives schemaZip
@@ -1497,22 +1282,6 @@ configure(project(':spring-core')) {
14971282
}
14981283
}
14991284

1500-
/*
1501-
* Copyright 2002-2016 the original author or authors.
1502-
*
1503-
* Licensed under the Apache License, Version 2.0 (the "License");
1504-
* you may not use this file except in compliance with the License.
1505-
* You may obtain a copy of the License at
1506-
*
1507-
* http://www.apache.org/licenses/LICENSE-2.0
1508-
*
1509-
* Unless required by applicable law or agreed to in writing, software
1510-
* distributed under the License is distributed on an "AS IS" BASIS,
1511-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1512-
* See the License for the specific language governing permissions and
1513-
* limitations under the License.
1514-
*/
1515-
15161285
/*
15171286
* Support publication of artifacts versioned by topic branch.
15181287
* CI builds supply `-P BRANCH_NAME=<TOPIC>` to gradle at build time.

0 commit comments

Comments
 (0)