1
1
plugins {
2
2
id ' org.antora' version ' 1.0.0-alpha.3'
3
- id ' org.springframework.antora.check-version'
4
3
}
5
4
6
5
apply plugin : ' io.spring.convention.docs'
@@ -15,10 +14,11 @@ antora {
15
14
' ALGOLIA_APP_ID' : ' 244V8V9FGG' ,
16
15
' ALGOLIA_INDEX_NAME' : ' security-docs'
17
16
]
17
+ dependencies = [
18
+ ' @antora/collector-extension' : ' 1.0.0-alpha.2'
19
+ ]
18
20
}
19
21
20
- tasks. antora. dependsOn ' generateAntora'
21
-
22
22
tasks. register(' generateAntora' ) {
23
23
group = ' Documentation'
24
24
description = ' Generates the antora.yml for dynamic properties'
@@ -33,21 +33,22 @@ tasks.register('generateAntora') {
33
33
def securityReferenceUrl = " $securityDocsUrl /reference/html5/"
34
34
def springFrameworkApiUrl = " https://docs.spring.io/spring-framework/docs/$springFrameworkVersion /javadoc-api/"
35
35
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
51
52
asciidoc:
52
53
attributes:
53
54
icondir: icons
@@ -60,7 +61,7 @@ asciidoc:
60
61
spring-framework-reference-url: $springFrameworkReferenceUrl
61
62
spring-security-version: ${ project.version}
62
63
${ ymlVersions}
63
- """ )
64
+ """
64
65
}
65
66
}
66
67
0 commit comments