11plugins {
22 id ' org.antora' version ' 1.0.0-alpha.3'
3- id ' org.springframework.antora.check-version'
43}
54
65apply plugin : ' io.spring.convention.docs'
@@ -15,10 +14,11 @@ antora {
1514 ' ALGOLIA_APP_ID' : ' 244V8V9FGG' ,
1615 ' ALGOLIA_INDEX_NAME' : ' security-docs'
1716 ]
17+ dependencies = [
18+ ' @antora/collector-extension' : ' 1.0.0-alpha.2'
19+ ]
1820}
1921
20- tasks. antora. dependsOn ' generateAntora'
21-
2222tasks. register(' generateAntora' ) {
2323 group = ' Documentation'
2424 description = ' Generates the antora.yml for dynamic properties'
@@ -33,21 +33,22 @@ tasks.register('generateAntora') {
3333 def securityReferenceUrl = " $securityDocsUrl /reference/html5/"
3434 def springFrameworkApiUrl = " https://docs.spring.io/spring-framework/docs/$springFrameworkVersion /javadoc-api/"
3535 def springFrameworkReferenceUrl = " https://docs.spring.io/spring-framework/docs/$springFrameworkVersion /reference/html/"
36- def versions = resolvedVersions(project. configurations. testRuntimeClasspath)
37- def ymlVersions = ' '
38- versions. call(). each { name , version ->
39- ymlVersions + = """
40- ${ name} : ${ version} """
41- }
42- def outputFile = layout. buildDirectory. file(' generateAntora/antora.yml' ). orNull. asFile
43- outputFile. getParentFile(). mkdirs()
44- outputFile. createNewFile()
45- def antoraYmlText = file(' antora.yml' ). text. trim()
46- outputFile. setText(""" $antoraYmlText
47- title: Spring Security
48- start_page: ROOT:index.adoc
49- nav:
50- - modules/ROOT/nav.adoc
36+ def ymlVersions = resolvedVersions(project. configurations. testRuntimeClasspath). call()
37+ .collect(v -> " ${ v.getKey()} : ${ v.getValue()} " )
38+ .join(' \n ' )
39+ def outputFile = layout. buildDirectory. file(' generateAntora/antora.yml' ). get(). asFile
40+ mkdir(outputFile. getParentFile())
41+ def (mainVersion, prerelease) = project. version. split(/ (?=-)/ , 2 )
42+ def antoraYmlText = file(' antora.yml' ). text
43+ layout. buildDirectory. file(' .antora.yml' ). get(). asFile. text = antoraYmlText
44+ antoraYmlText = antoraYmlText. lines(). collect { l ->
45+ if (l. startsWith(' version: ' )) {
46+ return prerelease == null ? " version: '${ mainVersion} '" : " version: '${ mainVersion} '\n prerelease: '${ prerelease} '"
47+ }
48+ if (l. startsWith(' title: ' )) return " title: ${ project.parent.description} "
49+ return l == ' ext:' || l. getAt(0 ) == ' ' ? null : l
50+ }. findAll(Objects ::nonNull). join(' \n ' )
51+ outputFile. text = """ $antoraYmlText
5152asciidoc:
5253 attributes:
5354 icondir: icons
@@ -60,7 +61,7 @@ asciidoc:
6061 spring-framework-reference-url: $springFrameworkReferenceUrl
6162 spring-security-version: ${ project.version}
6263${ ymlVersions}
63- """ )
64+ """
6465 }
6566}
6667
0 commit comments