|
|
|
@ -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,60 +17,9 @@ 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 { |
|
|
|
|
|
|
|
def docsTag = snapshotBuild ? 'current' : project.version |
|
|
|
|
|
|
|
def ghTag = snapshotBuild ? 'main' : project.version |
|
|
|
|
|
|
|
def ghUrl = "https://github.com/spring-projects/spring-security/tree/$ghTag" |
|
|
|
|
|
|
|
def ghOldSamplesUrl = 'https://github.com/spring-projects/spring-security/tree/5.4.x/samples' |
|
|
|
|
|
|
|
def ghSamplesUrl = "https://github.com/spring-projects/spring-security-samples/tree/$samplesBranch" |
|
|
|
|
|
|
|
def securityDocsUrl = "https://docs.spring.io/spring-security/site/docs/$docsTag" |
|
|
|
|
|
|
|
def securityApiUrl = "$securityDocsUrl/api/" |
|
|
|
|
|
|
|
def securityReferenceUrl = "$securityDocsUrl/reference/html5/" |
|
|
|
|
|
|
|
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 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 { |
|
|
|
dependencies { |
|
|
|
@ -79,12 +29,33 @@ dependencies { |
|
|
|
testImplementation 'org.springframework:spring-core' |
|
|
|
testImplementation 'org.springframework:spring-core' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generateAttributes() { |
|
|
|
|
|
|
|
def docsTag = snapshotBuild ? 'current' : project.version |
|
|
|
|
|
|
|
def ghTag = snapshotBuild ? 'main' : project.version |
|
|
|
|
|
|
|
def ghUrl = "https://github.com/spring-projects/spring-security/tree/$ghTag" |
|
|
|
|
|
|
|
def ghOldSamplesUrl = 'https://github.com/spring-projects/spring-security/tree/5.4.x/samples' |
|
|
|
|
|
|
|
def ghSamplesUrl = "https://github.com/spring-projects/spring-security-samples/tree/$samplesBranch" |
|
|
|
|
|
|
|
def securityDocsUrl = "https://docs.spring.io/spring-security/site/docs/$docsTag" |
|
|
|
|
|
|
|
def securityApiUrl = "$securityDocsUrl/api/" |
|
|
|
|
|
|
|
def securityReferenceUrl = "$securityDocsUrl/reference/html5/" |
|
|
|
|
|
|
|
def springFrameworkApiUrl = "https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/javadoc-api/" |
|
|
|
|
|
|
|
def springFrameworkReferenceUrl = "https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/reference/html/" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ['gh-old-samples-url': ghOldSamplesUrl.toString(), |
|
|
|
|
|
|
|
'gh-samples-url': ghSamplesUrl.toString(), |
|
|
|
|
|
|
|
'gh-url': ghUrl.toString(), |
|
|
|
|
|
|
|
'security-api-url': securityApiUrl.toString(), |
|
|
|
|
|
|
|
'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 { |
|
|
|
|