inject-collector-config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict'
  2. const BASE_COMMAND = 'gradlew -PbuildSrc.skipTests=true -Porg.gradle.java.installations.auto-detect=false --scan --stacktrace'
  3. const JVM_ARGS='-Xmx3g -XX:+HeapDumpOnOutOfMemoryError'
  4. const REPO_URL = 'https://github.com/spring-projects/spring-security'
  5. const TASK_NAME=':spring-security-docs:generateAntora'
  6. /**
  7. * Set of tags that contain a collector config, but the antora command fails on GitHub Actions.
  8. */
  9. const VERSIONS_TO_OVERRIDE = [
  10. '6.0.0-RC1'
  11. ]
  12. /**
  13. * The purpose of this extension is to inject the Antora Collector configuration into the parsed component version
  14. * descriptor in tags created before Antora Collector was introduced. Antora Collector runs a command to generate a
  15. * replacement antora.yml that a) sets the version from the value of the version property in gradle.properties and b)
  16. * populates AsciiDoc attributes with information from the Gradle build, such as software versions and resource URLs.
  17. */
  18. module.exports.register = function () {
  19. this.once('contentAggregated', ({ contentAggregate }) => {
  20. for (const { origins } of contentAggregate) {
  21. for (const origin of origins) {
  22. if (origin.url !== REPO_URL) {
  23. continue
  24. }
  25. // Ignore tags with their own collector config unless the antora command fails on GitHub Actions
  26. if (!(origin.descriptor.ext?.collector === undefined || VERSIONS_TO_OVERRIDE.includes(origin.tag))) {
  27. continue
  28. }
  29. origin.descriptor.ext = {
  30. collector: {
  31. run: { command: `${BASE_COMMAND} "-Dorg.gradle.jvmargs=${JVM_ARGS}" ${TASK_NAME}`, local: true },
  32. scan: { dir: './build/generateAntora' },
  33. }
  34. }
  35. }
  36. }
  37. })
  38. }