spring-security-docs.gradle 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. plugins {
  2. id 'org.antora' version '1.0.0-alpha.3'
  3. id 'org.springframework.antora.check-version'
  4. }
  5. apply plugin: 'io.spring.convention.docs'
  6. apply plugin: 'java'
  7. antora {
  8. version = '~3.1'
  9. playbook = file('local-antora-playbook.yml')
  10. options = ['--clean', '--stacktrace']
  11. environment = [
  12. 'ALGOLIA_API_KEY': '82c7ead946afbac3cf98c32446154691',
  13. 'ALGOLIA_APP_ID': '244V8V9FGG',
  14. 'ALGOLIA_INDEX_NAME': 'security-docs'
  15. ]
  16. }
  17. tasks.antora.dependsOn 'generateAntora'
  18. tasks.register('generateAntora') {
  19. group = 'Documentation'
  20. description = 'Generates the antora.yml for dynamic properties'
  21. doLast {
  22. def docsTag = snapshotBuild ? 'current' : project.version
  23. def ghTag = snapshotBuild ? 'main' : project.version
  24. def ghUrl = "https://github.com/spring-projects/spring-security/tree/$ghTag"
  25. def ghOldSamplesUrl = 'https://github.com/spring-projects/spring-security/tree/5.4.x/samples'
  26. def ghSamplesUrl = "https://github.com/spring-projects/spring-security-samples/tree/$samplesBranch"
  27. def securityDocsUrl = "https://docs.spring.io/spring-security/site/docs/$docsTag"
  28. def securityApiUrl = "$securityDocsUrl/api/"
  29. def securityReferenceUrl = "$securityDocsUrl/reference/html5/"
  30. def springFrameworkApiUrl = "https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/javadoc-api/"
  31. def springFrameworkReferenceUrl = "https://docs.spring.io/spring-framework/docs/$springFrameworkVersion/reference/html/"
  32. def versions = resolvedVersions(project.configurations.testRuntimeClasspath)
  33. def ymlVersions = ''
  34. versions.call().each { name, version ->
  35. ymlVersions += """
  36. ${name}: ${version}"""
  37. }
  38. def outputFile = layout.buildDirectory.file('generateAntora/antora.yml').orNull.asFile
  39. outputFile.getParentFile().mkdirs()
  40. outputFile.createNewFile()
  41. def antoraYmlText = file('antora.yml').text.trim()
  42. outputFile.setText("""$antoraYmlText
  43. title: Spring Security
  44. start_page: ROOT:index.adoc
  45. nav:
  46. - modules/ROOT/nav.adoc
  47. asciidoc:
  48. attributes:
  49. icondir: icons
  50. gh-old-samples-url: $ghOldSamplesUrl
  51. gh-samples-url: $ghSamplesUrl
  52. gh-url: $ghUrl
  53. security-api-url: $securityApiUrl
  54. security-reference-url: $securityReferenceUrl
  55. spring-framework-api-url: $springFrameworkApiUrl
  56. spring-framework-reference-url: $springFrameworkReferenceUrl
  57. spring-security-version: ${project.version}
  58. ${ymlVersions}
  59. """)
  60. }
  61. }
  62. dependencies {
  63. testImplementation platform(project(':spring-security-dependencies'))
  64. testImplementation 'com.unboundid:unboundid-ldapsdk'
  65. testImplementation 'org.apache.directory.server:apacheds-core'
  66. testImplementation 'org.springframework:spring-core'
  67. }
  68. def resolvedVersions(Configuration configuration) {
  69. return {
  70. configuration.resolvedConfiguration
  71. .resolvedArtifacts
  72. .collectEntries { [(it.name + '-version'): it.moduleVersion.id.version] }
  73. }
  74. }
  75. repositories {
  76. mavenCentral()
  77. maven { url 'https://repo.spring.io/release' }
  78. maven { url 'https://repo.spring.io/milestone' }
  79. maven { url 'https://repo.spring.io/snapshot' }
  80. }