Skip to content

Commit ca77a54

Browse files
committed
fix: cleanup doc build so it doesn't block the entire build
1 parent 45e98d8 commit ca77a54

File tree

1 file changed

+64
-94
lines changed

1 file changed

+64
-94
lines changed

grails-doc/build.gradle

Lines changed: 64 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import grails.doc.git.FetchTagsTask
2121
import grails.doc.dropdown.CreateReleaseDropDownTask
22-
import grails.doc.gradle.PublishGuide
22+
import grails.doc.gradle.PublishGuideTask
2323

2424
plugins {
2525
id 'base'
@@ -67,30 +67,30 @@ combinedGroovydoc.configure { Groovydoc gdoc ->
6767
.findAll { it.findProperty('includeInApiDocs') }
6868

6969
def sources = docProjects
70-
.collectMany {Project it ->
70+
.collectMany { Project it ->
7171
List possibleSources = [it.sourceSets.main]
7272

7373
def testFixturesSource = it.sourceSets.findByName('testFixtures')
74-
if(testFixturesSource) {
74+
if (testFixturesSource) {
7575
possibleSources.add(testFixturesSource)
7676
}
7777

7878
def astSource = it.sourceSets.findByName('ast')
79-
if(astSource) {
79+
if (astSource) {
8080
possibleSources.add(astSource)
8181
}
8282
possibleSources
8383
}
8484
.flatten()
85-
gdoc.source(sources.collect{ SourceSet it -> [it.allSource.srcDirs, it.allSource.srcDirs] }.flatten().findAll { File srcDir ->
86-
if(!(srcDir.name in ['java', 'groovy'])) {
85+
gdoc.source(sources.collect { SourceSet it -> [it.allSource.srcDirs, it.allSource.srcDirs] }.flatten().findAll { File srcDir ->
86+
if (!(srcDir.name in ['java', 'groovy'])) {
8787
return false
8888
}
8989

9090
srcDir.exists()
9191
}.unique())
9292

93-
gdoc.classpath = files(sources.collect{ SourceSet it -> it.compileClasspath.filter(File.&isDirectory) }.flatten().unique())
93+
gdoc.classpath = files(sources.collect { SourceSet it -> it.compileClasspath.filter(File.&isDirectory) }.flatten().unique())
9494
gdoc.destinationDir = project.layout.buildDirectory.dir('combined-api/api').get().asFile
9595

9696
gdoc.inputs.files(gdoc.source)
@@ -102,68 +102,54 @@ System.setProperty('grails.docs.clean.html', 'true')
102102
// creates single.html.before.xml and single.html.after.xml files for debugging pdf input when enabled
103103
//System.setProperty('grails.docs.debug.pdf','true')
104104

105-
asciidoctor {
106-
resources {
107-
from('resources')
108-
}
109-
110-
options template_dirs: ["${projectDir}/src/docs/templates"]
111-
attributes 'experimental': 'true',
112-
'compat-mode': 'true',
113-
'icons': 'font',
114-
'linkcss': 'true',
115-
'docinfo1': '',
116-
'toc': 'left',
117-
'version': project.version,
118-
'sourcedir': rootProject.projectDir.absolutePath
119-
}
120-
121-
asciidoctor.dependsOn('aggregateGroovydoc')
122-
123-
tasks.register('dist', Zip).configure { Zip it ->
124-
it.dependsOn 'docs'
125-
it.from outputDir
126-
}
127-
128-
tasks.register('fetchTags', FetchTagsTask)
129-
130-
tasks.register('createReleaseDropdown', CreateReleaseDropDownTask).configure { CreateReleaseDropDownTask it ->
131-
it.group = 'documentation'
132-
it.dependsOn 'publishGuide'
133-
134-
it.inputFiles = project.layout.buildDirectory.files('modified-guide/guide/single.html', 'modified-guide/index.html')
135-
it.docsDirectory = project.layout.buildDirectory.dir('original-guide')
136-
it.outputDir = project.layout.buildDirectory.dir('modified-guide')
137-
}
138-
139-
tasks.register('resolveGroovyVersion').configure { Task versionTask ->
140-
versionTask.group = 'documentation'
141-
versionTask.description = 'Resolve Groovy Version from the BOM'
142-
ext.resolved = configurations.compileClasspath
143-
.resolvedConfiguration
144-
.resolvedArtifacts
145-
.find {
146-
it.moduleVersion.id.group == 'org.apache.groovy' &&
147-
it.moduleVersion.id.name.contains('groovy')
148-
}.moduleVersion.id.version
149-
logger.lifecycle('Resolved Groovy version for Guide links: {}', ext.resolved)
150-
}
151-
152105
String getVersion(String artifact) {
153106
String version = configurations.runtimeClasspath
154107
.resolvedConfiguration
155108
.resolvedArtifacts
156109
.find {
157110
it.moduleVersion.id.name == artifact
158111
}?.moduleVersion?.id?.version
159-
if(!version) {
112+
if (!version) {
160113
throw new GradleException("Could not find ${artifact} version.")
161114
}
162115
version
163116
}
164117

165-
tasks.register('publishGuide', PublishGuide).configure { PublishGuide publish ->
166-
publish.dependsOn(['generateBomDocumentation', 'aggregateGroovydoc', 'jar', 'resolveGroovyVersion', 'processTestResources', 'compileTestJava', 'compileTestGroovy', 'test'])
118+
def generateBomDocumentation = tasks.register('generateBomDocumentation')
119+
generateBomDocumentation.configure { Task it ->
120+
it.dependsOn(':grails-bom:extractConstraints')
121+
122+
it.description = 'Generates an AsciiDoc table listing Group, Artifact, and Version for project dependencies.'
123+
it.group = 'documentation'
124+
125+
it.inputs.files(project(':grails-bom').layout.projectDirectory.asFileTree)
126+
it.outputs.file(project.layout.projectDirectory.file('src/en/ref/Versions/Grails BOM.adoc'))
127+
128+
def versionsDir = project.layout.projectDirectory.dir('src/en/ref/Versions')
129+
it.doFirst {
130+
versionsDir.asFile.mkdirs()
131+
}
132+
133+
def bomDocumentFile = project.layout.projectDirectory.file('src/en/ref/Versions/Grails BOM.adoc')
134+
def grailsBomConstraintFile = project(':grails-bom').layout.buildDirectory.file('grails-bom-constraints.adoc')
135+
it.doLast {
136+
def bomDocument = bomDocumentFile.asFile
137+
bomDocument.withWriter { writer ->
138+
writer.writeLine '== Grails BOM Dependencies'
139+
writer.writeLine ''
140+
writer.writeLine 'This document provides information about the dependencies defined in the Grails BOM - also known as `org.apache.grails:grails-bom`. It includes the artifact coordinates, where in the hierarchy the coordinate was defined, and the maven property that defines the version.'
141+
writer.writeLine ''
142+
writer.write(grailsBomConstraintFile.get().asFile.text)
143+
writer.writeLine ''
144+
}
145+
146+
it.logger.lifecycle "BOM Dependency Page generated to: ${bomDocument.absolutePath}"
147+
}
148+
}
149+
150+
def publishGuideTask = tasks.register('publishGuide', PublishGuideTask)
151+
publishGuideTask.configure { PublishGuideTask publish ->
152+
publish.dependsOn([generateBomDocumentation])
167153

168154
// No language setting because we want the English guide to be
169155
// generated with a 'en' in the path, but the source is in 'en'
@@ -178,15 +164,15 @@ tasks.register('publishGuide', PublishGuide).configure { PublishGuide publish ->
178164
publish.properties = project.provider {
179165
def springVersion = getVersion('spring-core')
180166
def springBootVersion = getVersion('spring-boot')
181-
167+
def groovyVersion = getVersion('groovy') as String
182168
[
183169
'api' : '../api',
184170
'safe' : 'UNSAFE', // Make sure any asciidoc security is disabled
185171
'jakartaee' : 'https://jakarta.ee/specifications/platform/10/apidocs/',
186172
'javase' : "https://docs.oracle.com/en/java/javase/${javaVersion}/docs/api/",
187-
'groovyapi' : "https://docs.groovy-lang.org/${resolveGroovyVersion.resolved}/html/gapi/",
188-
'groovyjdk' : "https://docs.groovy-lang.org/${resolveGroovyVersion.resolved}/html/groovy-jdk/",
189-
'groovyVersion' : resolveGroovyVersion.resolved,
173+
'groovyapi' : "https://docs.groovy-lang.org/${groovyVersion}/html/gapi/",
174+
'groovyjdk' : "https://docs.groovy-lang.org/${groovyVersion}/html/groovy-jdk/",
175+
'groovyVersion' : groovyVersion,
190176
'springapi' : "https://docs.spring.io/spring/docs/${springVersion}/javadoc-api/",
191177
'springdocs' : "https://docs.spring.io/spring/docs/${springVersion}/",
192178
'githubBranch' : githubBranch,
@@ -219,44 +205,23 @@ tasks.register('publishGuide', PublishGuide).configure { PublishGuide publish ->
219205
}
220206
}
221207

222-
tasks.register('generateBomDocumentation').configure { Task it ->
223-
it.dependsOn(':grails-bom:extractConstraints')
224-
225-
it.description = 'Generates an AsciiDoc table listing Group, Artifact, and Version for project dependencies.'
226-
it.group = 'documentation'
227-
228-
it.inputs.files(project(':grails-bom').layout.projectDirectory.asFileTree)
229-
it.outputs.file(project.layout.projectDirectory.file('src/en/ref/Versions/Grails BOM.adoc'))
208+
def createReleaseDropdownTask = tasks.register('createReleaseDropdown', CreateReleaseDropDownTask)
209+
createReleaseDropdownTask.configure { CreateReleaseDropDownTask it ->
210+
it.dependsOn(publishGuideTask)
230211

231-
def versionsDir = project.layout.projectDirectory.dir('src/en/ref/Versions')
232-
it.doFirst {
233-
versionsDir.asFile.mkdirs()
234-
}
235-
236-
def bomDocumentFile = project.layout.projectDirectory.file('src/en/ref/Versions/Grails BOM.adoc')
237-
def grailsBomConstraintFile = project(':grails-bom').layout.buildDirectory.file('grails-bom-constraints.adoc')
238-
it.doLast {
239-
def bomDocument = bomDocumentFile.asFile
240-
bomDocument.withWriter { writer ->
241-
writer.writeLine '== Grails BOM Dependencies'
242-
writer.writeLine ''
243-
writer.writeLine 'This document provides information about the dependencies defined in the Grails BOM - also known as `org.apache.grails:grails-bom`. It includes the artifact coordinates, where in the hierarchy the coordinate was defined, and the maven property that defines the version.'
244-
writer.writeLine ''
245-
writer.write(grailsBomConstraintFile.get().asFile.text)
246-
writer.writeLine ''
247-
}
248-
249-
it.logger.lifecycle "BOM Dependency Page generated to: ${bomDocument.absolutePath}"
250-
}
212+
it.filesToAddDropdowns = project.layout.buildDirectory.files('modified-guide/guide/single.html', 'modified-guide/index.html')
213+
it.sourceDocsDirectory = project.layout.buildDirectory.dir('original-guide')
214+
it.modifiedPagesDirectory = project.layout.buildDirectory.dir('modified-guide')
251215
}
252216

253-
tasks.register('generateGuide').configure { Task task ->
254-
task.dependsOn('createReleaseDropdown')
255-
task.group = 'documentation'
217+
def fetchTagsTask = project.tasks.register('fetchTags', FetchTagsTask)
218+
createReleaseDropdownTask.configure {
219+
dependsOn(fetchTagsTask)
256220
}
257221

258-
tasks.register('docs', Sync).configure { Sync it ->
259-
it.dependsOn 'aggregateGroovydoc', 'generateGuide', ':grails-data-docs-stage:docs'
222+
def docsTask = tasks.register('docs', Sync)
223+
docsTask.configure { Sync it ->
224+
it.dependsOn(combinedGroovydoc, createReleaseDropdownTask, ':grails-data-docs-stage:docs')
260225
it.group = 'documentation'
261226

262227
def manualDocsDir = project.layout.buildDirectory.dir('modified-guide')
@@ -276,6 +241,11 @@ tasks.register('docs', Sync).configure { Sync it ->
276241
it.into mergedDocsDir
277242
}
278243

244+
tasks.register('dist', Zip).configure { Zip it ->
245+
it.dependsOn(docsTask)
246+
it.from(outputDir)
247+
}
248+
279249
artifacts {
280250
archives dist
281251
}

0 commit comments

Comments
 (0)