inject-collector-config.js 1.3 KB

12345678910111213141516171819202122232425262728
  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. * The purpose of this extension is to inject the Antora Collector configuration into the parsed component version
  8. * descriptor in tags created before Antora Collector was introduced. Antora Collector runs a command to generate a
  9. * replacement antora.yml that a) sets the version from the value of the version property in gradle.properties and b)
  10. * populates AsciiDoc attributes with information from the Gradle build, such as software versions and resource URLs.
  11. */
  12. module.exports.register = function () {
  13. this.once('contentAggregated', ({ contentAggregate }) => {
  14. for (const { origins } of contentAggregate) {
  15. for (const origin of origins) {
  16. if (!(origin.url === REPO_URL && origin.descriptor.ext?.collector === undefined)) continue
  17. origin.descriptor.ext = {
  18. collector: {
  19. run: { command: `${BASE_COMMAND} "-Dorg.gradle.jvmargs=${JVM_ARGS}" ${TASK_NAME}`, local: true },
  20. scan: { dir: './build/generateAntora' },
  21. }
  22. }
  23. }
  24. }
  25. })
  26. }