mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-03-01 10:59:16 +00:00
Use io.spring.antora.generate-antora-yml
This commit is contained in:
parent
f5bc6ce665
commit
7db357d36a
@ -6,7 +6,13 @@ nav:
|
|||||||
ext:
|
ext:
|
||||||
collector:
|
collector:
|
||||||
run:
|
run:
|
||||||
command: gradlew -q -PbuildSrc.skipTests=true "-Dorg.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError" :spring-security-docs:generateAntora
|
command: gradlew -q -PbuildSrc.skipTests=true "-Dorg.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError" :spring-security-docs:generateAntoraYml
|
||||||
local: true
|
local: true
|
||||||
scan:
|
scan:
|
||||||
dir: ./build/generateAntora
|
dir: ./build/generated-antora-resources
|
||||||
|
asciidoc:
|
||||||
|
attributes:
|
||||||
|
icondir: icons
|
||||||
|
gh-old-samples-url: 'https://github.com/spring-projects/spring-security/tree/5.4.x/samples'
|
||||||
|
gh-samples-url: "https://github.com/spring-projects/spring-security-samples/tree/{gh-tag}"
|
||||||
|
gh-url: "https://github.com/spring-projects/spring-security/tree/{gh-tag}"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'org.antora' version '1.0.0-alpha.7'
|
id 'org.antora' version '1.0.0-alpha.7'
|
||||||
|
id 'io.spring.antora.generate-antora-yml' version '0.0.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'io.spring.convention.docs'
|
apply plugin: 'io.spring.convention.docs'
|
||||||
@ -16,10 +17,19 @@ antora {
|
|||||||
options = [clean: true, fetch: !project.gradle.startParameter.offline, stacktrace: true]
|
options = [clean: true, fetch: !project.gradle.startParameter.offline, stacktrace: true]
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register('generateAntora') {
|
tasks.named("generateAntoraYml") {
|
||||||
group = 'Documentation'
|
asciidocAttributes = project.provider( { generateAttributes() } )
|
||||||
description = 'Generates the antora.yml for dynamic properties'
|
asciidocAttributes.putAll(providers.provider( { resolvedVersions(project.configurations.testRuntimeClasspath) }))
|
||||||
doLast {
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation platform(project(':spring-security-dependencies'))
|
||||||
|
testImplementation 'com.unboundid:unboundid-ldapsdk'
|
||||||
|
testImplementation 'org.apache.directory.server:apacheds-core'
|
||||||
|
testImplementation 'org.springframework:spring-core'
|
||||||
|
}
|
||||||
|
|
||||||
|
def generateAttributes() {
|
||||||
def docsTag = snapshotBuild ? 'current' : project.version
|
def docsTag = snapshotBuild ? 'current' : project.version
|
||||||
def ghTag = snapshotBuild ? 'main' : project.version
|
def ghTag = snapshotBuild ? 'main' : project.version
|
||||||
def ghUrl = "https://github.com/spring-projects/spring-security/tree/$ghTag"
|
def ghUrl = "https://github.com/spring-projects/spring-security/tree/$ghTag"
|
||||||
@ -30,61 +40,22 @@ tasks.register('generateAntora') {
|
|||||||
def securityReferenceUrl = "$securityDocsUrl/reference/html5/"
|
def securityReferenceUrl = "$securityDocsUrl/reference/html5/"
|
||||||
def springFrameworkApiUrl = "https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/javadoc-api/"
|
def springFrameworkApiUrl = "https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/javadoc-api/"
|
||||||
def springFrameworkReferenceUrl = "https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/reference/html/"
|
def springFrameworkReferenceUrl = "https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/reference/html/"
|
||||||
def ymlVersions = resolvedVersions(project.configurations.testRuntimeClasspath).call()
|
|
||||||
.collect(v -> " ${v.getKey()}: ${v.getValue()}")
|
|
||||||
.join('\n')
|
|
||||||
def outputFile = layout.buildDirectory.file('generateAntora/antora.yml').get().asFile
|
|
||||||
mkdir(outputFile.getParentFile())
|
|
||||||
def mainVersion = project.version
|
|
||||||
def prerelease = null
|
|
||||||
def versionComponents = mainVersion.split(/(?=-)/)
|
|
||||||
if (versionComponents.length > 1) {
|
|
||||||
if (versionComponents[1] == '-SNAPSHOT') {
|
|
||||||
mainVersion = versionComponents[0]
|
|
||||||
prerelease = "'-SNAPSHOT'"
|
|
||||||
} else {
|
|
||||||
prerelease = 'true'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
def antoraYmlText = file('antora.yml').text
|
|
||||||
layout.buildDirectory.file('.antora.yml').get().asFile.text = antoraYmlText
|
|
||||||
antoraYmlText = antoraYmlText.lines().collect { l ->
|
|
||||||
if (l.startsWith('version: ')) {
|
|
||||||
return prerelease == null ? "version: '${mainVersion}'" : "version: '${mainVersion}'\nprerelease: ${prerelease}"
|
|
||||||
}
|
|
||||||
if (l.startsWith('title: ')) return "title: ${project.parent.description}"
|
|
||||||
return l == 'ext:' || l.getAt(0) == ' ' ? null : l
|
|
||||||
}.findAll(Objects::nonNull).join('\n')
|
|
||||||
outputFile.text = """$antoraYmlText
|
|
||||||
asciidoc:
|
|
||||||
attributes:
|
|
||||||
icondir: icons
|
|
||||||
gh-old-samples-url: $ghOldSamplesUrl
|
|
||||||
gh-samples-url: $ghSamplesUrl
|
|
||||||
gh-url: $ghUrl
|
|
||||||
security-api-url: $securityApiUrl
|
|
||||||
security-reference-url: $securityReferenceUrl
|
|
||||||
spring-framework-api-url: $springFrameworkApiUrl
|
|
||||||
spring-framework-reference-url: $springFrameworkReferenceUrl
|
|
||||||
spring-security-version: ${project.version}
|
|
||||||
${ymlVersions}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
return ['gh-old-samples-url': ghOldSamplesUrl.toString(),
|
||||||
testImplementation platform(project(':spring-security-dependencies'))
|
'gh-samples-url': ghSamplesUrl.toString(),
|
||||||
testImplementation 'com.unboundid:unboundid-ldapsdk'
|
'gh-url': ghUrl.toString(),
|
||||||
testImplementation 'org.apache.directory.server:apacheds-core'
|
'security-api-url': securityApiUrl.toString(),
|
||||||
testImplementation 'org.springframework:spring-core'
|
'security-reference-url': securityReferenceUrl.toString(),
|
||||||
|
'spring-framework-api-url': springFrameworkApiUrl.toString(),
|
||||||
|
'spring-framework-reference-url': springFrameworkReferenceUrl.toString(),
|
||||||
|
'spring-security-version': project.version]
|
||||||
|
+ resolvedVersions(project.configurations.testRuntimeClasspath)
|
||||||
}
|
}
|
||||||
|
|
||||||
def resolvedVersions(Configuration configuration) {
|
def resolvedVersions(Configuration configuration) {
|
||||||
return {
|
return configuration.resolvedConfiguration
|
||||||
configuration.resolvedConfiguration
|
|
||||||
.resolvedArtifacts
|
.resolvedArtifacts
|
||||||
.collectEntries { [(it.name + '-version'): it.moduleVersion.id.version] }
|
.collectEntries { [(it.name + '-version'): it.moduleVersion.id.version] }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user