1
1
plugins {
2
2
id ' org.antora' version ' 1.0.0-alpha.7'
3
+ id ' io.spring.antora.generate-antora-yml' version ' 0.0.1'
3
4
}
4
5
5
6
apply plugin : ' io.spring.convention.docs'
@@ -16,60 +17,9 @@ antora {
16
17
options = [clean : true , fetch : ! project. gradle. startParameter. offline, stacktrace : true ]
17
18
}
18
19
19
- tasks. register(' generateAntora' ) {
20
- group = ' Documentation'
21
- description = ' Generates the antora.yml for dynamic properties'
22
- doLast {
23
- def docsTag = snapshotBuild ? ' current' : project. version
24
- def ghTag = snapshotBuild ? ' main' : project. version
25
- def ghUrl = " https://github.com/spring-projects/spring-security/tree/$ghTag "
26
- def ghOldSamplesUrl = ' https://github.com/spring-projects/spring-security/tree/5.4.x/samples'
27
- def ghSamplesUrl = " https://github.com/spring-projects/spring-security-samples/tree/$samplesBranch "
28
- def securityDocsUrl = " https://docs.spring.io/spring-security/site/docs/$docsTag "
29
- def securityApiUrl = " $securityDocsUrl /api/"
30
- def securityReferenceUrl = " $securityDocsUrl /reference/html5/"
31
- def springFrameworkApiUrl = " https://docs.spring.io/spring-framework/docs/$springFrameworkVersion /javadoc-api/"
32
- def springFrameworkReferenceUrl = " https://docs.spring.io/spring-framework/docs/$springFrameworkVersion /reference/html/"
33
- def ymlVersions = resolvedVersions(project. configurations. testRuntimeClasspath). call()
34
- .collect(v -> " ${ v.getKey()} : ${ v.getValue()} " )
35
- .join(' \n ' )
36
- def outputFile = layout. buildDirectory. file(' generateAntora/antora.yml' ). get(). asFile
37
- mkdir(outputFile. getParentFile())
38
- def mainVersion = project. version
39
- def prerelease = null
40
- def versionComponents = mainVersion. split(/ (?=-)/ )
41
- if (versionComponents. length > 1 ) {
42
- if (versionComponents[1 ] == ' -SNAPSHOT' ) {
43
- mainVersion = versionComponents[0 ]
44
- prerelease = " '-SNAPSHOT'"
45
- } else {
46
- prerelease = ' true'
47
- }
48
- }
49
- def antoraYmlText = file(' antora.yml' ). text
50
- layout. buildDirectory. file(' .antora.yml' ). get(). asFile. text = antoraYmlText
51
- antoraYmlText = antoraYmlText. lines(). collect { l ->
52
- if (l. startsWith(' version: ' )) {
53
- return prerelease == null ? " version: '${ mainVersion} '" : " version: '${ mainVersion} '\n prerelease: ${ prerelease} "
54
- }
55
- if (l. startsWith(' title: ' )) return " title: ${ project.parent.description} "
56
- return l == ' ext:' || l. getAt(0 ) == ' ' ? null : l
57
- }. findAll(Objects ::nonNull). join(' \n ' )
58
- outputFile. text = """ $antoraYmlText
59
- asciidoc:
60
- attributes:
61
- icondir: icons
62
- gh-old-samples-url: $ghOldSamplesUrl
63
- gh-samples-url: $ghSamplesUrl
64
- gh-url: $ghUrl
65
- security-api-url: $securityApiUrl
66
- security-reference-url: $securityReferenceUrl
67
- spring-framework-api-url: $springFrameworkApiUrl
68
- spring-framework-reference-url: $springFrameworkReferenceUrl
69
- spring-security-version: ${ project.version}
70
- ${ ymlVersions}
71
- """
72
- }
20
+ tasks. named(" generateAntoraYml" ) {
21
+ asciidocAttributes = project. provider( { generateAttributes() } )
22
+ asciidocAttributes. putAll(providers. provider( { resolvedVersions(project. configurations. testRuntimeClasspath) }))
73
23
}
74
24
75
25
dependencies {
@@ -79,12 +29,33 @@ dependencies {
79
29
testImplementation ' org.springframework:spring-core'
80
30
}
81
31
32
+ def generateAttributes () {
33
+ def docsTag = snapshotBuild ? ' current' : project. version
34
+ def ghTag = snapshotBuild ? ' main' : project. version
35
+ def ghUrl = " https://github.com/spring-projects/spring-security/tree/$ghTag "
36
+ def ghOldSamplesUrl = ' https://github.com/spring-projects/spring-security/tree/5.4.x/samples'
37
+ def ghSamplesUrl = " https://github.com/spring-projects/spring-security-samples/tree/$samplesBranch "
38
+ def securityDocsUrl = " https://docs.spring.io/spring-security/site/docs/$docsTag "
39
+ def securityApiUrl = " $securityDocsUrl /api/"
40
+ def securityReferenceUrl = " $securityDocsUrl /reference/html5/"
41
+ def springFrameworkApiUrl = " https://docs.spring.io/spring-framework/docs/$springFrameworkVersion /javadoc-api/"
42
+ def springFrameworkReferenceUrl = " https://docs.spring.io/spring-framework/docs/$springFrameworkVersion /reference/html/"
43
+
44
+ return [' gh-old-samples-url' : ghOldSamplesUrl. toString(),
45
+ ' gh-samples-url' : ghSamplesUrl. toString(),
46
+ ' gh-url' : ghUrl. toString(),
47
+ ' security-api-url' : securityApiUrl. toString(),
48
+ ' security-reference-url' : securityReferenceUrl. toString(),
49
+ ' spring-framework-api-url' : springFrameworkApiUrl. toString(),
50
+ ' spring-framework-reference-url' : springFrameworkReferenceUrl. toString(),
51
+ ' spring-security-version' : project. version]
52
+ + resolvedVersions(project. configurations. testRuntimeClasspath)
53
+ }
54
+
82
55
def resolvedVersions (Configuration configuration ) {
83
- return {
84
- configuration. resolvedConfiguration
56
+ return configuration. resolvedConfiguration
85
57
.resolvedArtifacts
86
58
.collectEntries { [(it. name + ' -version' ): it. moduleVersion. id. version] }
87
- }
88
59
}
89
60
90
61
repositories {
0 commit comments