spring-security-docs.gradle 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 'org.apache.directory.server:apacheds-core'
  32. testImplementation 'org.springframework:spring-core'
  33. }
  34. def generateAttributes() {
  35. def springFrameworkVersion = libs.org.springframework.spring.framework.bom.get().versionConstraint.displayName
  36. springFrameworkVersion = springFrameworkVersion.contains("-")
  37. ? springFrameworkVersion.substring(0, springFrameworkVersion.indexOf("-"))
  38. : springFrameworkVersion
  39. def springBootVersion = project.property("springBootVersion")
  40. def samplesBranch = project.property("samplesBranch")
  41. def docsTag = snapshotBuild ? 'current' : project.version
  42. def ghTag = snapshotBuild ? 'main' : project.version
  43. def ghUrl = "https://github.com/spring-projects/spring-security/tree/$ghTag"
  44. def ghOldSamplesUrl = 'https://github.com/spring-projects/spring-security/tree/5.4.x/samples'
  45. def ghSamplesUrl = "https://github.com/spring-projects/spring-security-samples/tree/$samplesBranch"
  46. def securityDocsUrl = "https://docs.spring.io/spring-security/site/docs/$docsTag"
  47. def securityApiUrl = "$securityDocsUrl/api/"
  48. def securityReferenceUrl = "$securityDocsUrl/reference/html5/"
  49. def springFrameworkApiUrl = "https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/javadoc-api/"
  50. def springFrameworkReferenceUrl = "https://docs.spring.io/spring-framework/reference/$springFrameworkVersion/"
  51. def springBootReferenceUrl = "https://docs.spring.io/spring-boot/$springBootVersion/"
  52. def springBootApiUrl = "https://docs.spring.io/spring-boot/$springBootVersion/api/java/"
  53. return ['gh-old-samples-url': ghOldSamplesUrl.toString(),
  54. 'gh-samples-url': ghSamplesUrl.toString(),
  55. 'gh-url': ghUrl.toString(),
  56. 'security-api-url': securityApiUrl.toString(),
  57. 'security-reference-url': securityReferenceUrl.toString(),
  58. 'spring-framework-api-url': springFrameworkApiUrl.toString(),
  59. 'spring-framework-reference-url': springFrameworkReferenceUrl.toString(),
  60. 'spring-boot-api-url': springBootApiUrl.toString(),
  61. 'spring-boot-reference-url': springBootReferenceUrl.toString(),
  62. 'spring-security-version': project.version]
  63. + resolvedVersions(project.configurations.testRuntimeClasspath)
  64. }
  65. def resolvedVersions(Configuration configuration) {
  66. return configuration.resolvedConfiguration
  67. .resolvedArtifacts
  68. .collectEntries { [(it.name + '-version'): it.moduleVersion.id.version] }
  69. }