spring-security-docs.gradle 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. plugins {
  2. id 'org.antora' version '1.0.0'
  3. id 'io.spring.antora.generate-antora-yml' version '0.0.1'
  4. id 'io.spring.convention.repository'
  5. }
  6. apply plugin: 'io.spring.convention.docs'
  7. apply plugin: 'java'
  8. antora {
  9. options = [clean: true, fetch: !project.gradle.startParameter.offline, stacktrace: true]
  10. environment = [
  11. 'BUILD_REFNAME': 'HEAD',
  12. 'BUILD_VERSION': project.version,
  13. ]
  14. }
  15. tasks.register("syncAntoraAttachments", Sync) {
  16. group = 'Documentation'
  17. description = 'Syncs the Antora attachments'
  18. from project.provider( { project.tasks.api.outputs } )
  19. into project.layout.buildDirectory.dir('generated-antora-resources/modules/ROOT/assets/attachments/api/java')
  20. }
  21. tasks.named("generateAntoraYml") {
  22. asciidocAttributes = project.provider( { generateAttributes() } )
  23. asciidocAttributes.putAll(providers.provider( { resolvedVersions(project.configurations.testRuntimeClasspath) }))
  24. }
  25. tasks.register("generateAntoraResources") {
  26. dependsOn 'generateAntoraYml', 'syncAntoraAttachments'
  27. }
  28. dependencies {
  29. testImplementation platform(project(':spring-security-dependencies'))
  30. testImplementation 'com.unboundid:unboundid-ldapsdk'
  31. testImplementation libs.webauthn4j.core
  32. testImplementation 'org.apache.directory.server:apacheds-core'
  33. testImplementation 'org.springframework:spring-core'
  34. }
  35. def generateAttributes() {
  36. def springFrameworkVersion = libs.org.springframework.spring.framework.bom.get().versionConstraint.displayName
  37. springFrameworkVersion = springFrameworkVersion.contains("-")
  38. ? springFrameworkVersion.substring(0, springFrameworkVersion.indexOf("-"))
  39. : springFrameworkVersion
  40. def springBootVersion = project.property("springBootVersion")
  41. def samplesBranch = project.property("samplesBranch")
  42. def docsTag = snapshotBuild ? 'current' : project.version
  43. def ghTag = snapshotBuild ? 'main' : project.version
  44. def ghUrl = "https://github.com/spring-projects/spring-security/tree/$ghTag"
  45. def ghOldSamplesUrl = 'https://github.com/spring-projects/spring-security/tree/5.4.x/samples'
  46. def ghSamplesUrl = "https://github.com/spring-projects/spring-security-samples/tree/$samplesBranch"
  47. def securityDocsUrl = "https://docs.spring.io/spring-security/site/docs/$docsTag"
  48. def securityApiUrl = "$securityDocsUrl/api/"
  49. def securityReferenceUrl = "$securityDocsUrl/reference/html5/"
  50. def springFrameworkApiUrl = "https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/javadoc-api/"
  51. def springFrameworkReferenceUrl = "https://docs.spring.io/spring-framework/reference/$springFrameworkVersion/"
  52. def springBootReferenceUrl = "https://docs.spring.io/spring-boot/$springBootVersion/"
  53. def springBootApiUrl = "https://docs.spring.io/spring-boot/$springBootVersion/api/java/"
  54. return ['gh-old-samples-url': ghOldSamplesUrl.toString(),
  55. 'gh-samples-url': ghSamplesUrl.toString(),
  56. 'gh-url': ghUrl.toString(),
  57. 'security-api-url': securityApiUrl.toString(),
  58. 'security-reference-url': securityReferenceUrl.toString(),
  59. 'spring-framework-api-url': springFrameworkApiUrl.toString(),
  60. 'spring-framework-reference-url': springFrameworkReferenceUrl.toString(),
  61. 'spring-boot-api-url': springBootApiUrl.toString(),
  62. 'spring-boot-reference-url': springBootReferenceUrl.toString(),
  63. 'spring-security-version': project.version]
  64. + resolvedVersions(project.configurations.testRuntimeClasspath)
  65. }
  66. def resolvedVersions(Configuration configuration) {
  67. return configuration.resolvedConfiguration
  68. .resolvedArtifacts
  69. .collectEntries { [(it.name + '-version'): it.moduleVersion.id.version] }
  70. }