Skip to content

feat: publish Groovydoc Enhancer Plugin for use in end-user Grails apps#15430

Draft
jamesfredley wants to merge 8 commits into7.0.xfrom
feat/publish-groovydoc-plugin
Draft

feat: publish Groovydoc Enhancer Plugin for use in end-user Grails apps#15430
jamesfredley wants to merge 8 commits into7.0.xfrom
feat/publish-groovydoc-plugin

Conversation

@jamesfredley
Copy link
Contributor

Summary

Potential path to allow end-user Grails applications to use modern Java features (17+) and still generate accurate Groovydoc documentation.

Gradle's built-in Groovydoc task does not expose the javaVersion parameter (added in Groovy 4.0.27 via GROOVY-11668), so projects using Java 17+ features (sealed classes, records, pattern matching, text blocks, etc.) fail to generate Groovydoc. This PR publishes the GroovydocEnhancerPlugin (from #15420) as a standalone Gradle plugin that end-user Grails applications can consume.

Changes

New Published Module: grails-gradle-groovydoc

  • Maven coordinate: org.apache.grails.gradle:grails-gradle-groovydoc
  • Plugin ID: org.apache.grails.gradle.groovydoc
  • Located in grails-gradle/groovydoc/ following the existing grails-gradle subproject pattern
  • Automatically included in grails-gradle-bom (subproject auto-inclusion)
  • Manually added to grails-bom via gradleBuildProjects map for end-user app BOM resolution

Forge Integration (DefaultFeature)

  • New GroovydocEnhancer feature class applied to all generated Grails applications by default
  • Adds grails-gradle-groovydoc as a buildscript classpath dependency (version managed by grails-bom)
  • Applies org.apache.grails.gradle.groovydoc plugin via apply plugin

Profile Integration

  • Updated base/profile.yml to include the plugin for grails CLI-based app generation
  • Both forge and profile paths now generate apps with Groovydoc enhancer support

Build-Logic

  • build-logic/ retains its own copy of the plugin for the framework build itself (bootstrap constraint - build-logic cannot depend on grails-gradle artifacts without circular dependency)
  • The published grails-gradle-groovydoc module is the canonical version for end-user consumption

Architecture Note

There are two copies of the enhancer plugin:

  1. build-logic/plugins/ - convention plugin for building grails-core itself (unpublished, internal)
  2. grails-gradle/groovydoc/ - published plugin for end-user Grails apps

This duplication exists because build-logic is evaluated before grails-gradle builds, creating a bootstrap dependency that prevents build-logic from consuming the published artifact directly. Future work could explore composite build substitution or a shared source set to eliminate this duplication.

Testing

  • grails-gradle-groovydoc builds successfully standalone
  • grails-bom POM generation succeeds with the new artifact
  • grails-forge-core compiles with the new feature class
  • Code style checks pass

Depends On

jamesfredley and others added 6 commits February 19, 2026 20:00
Replace Gradle's built-in Groovydoc task execution with AntBuilder to
support the javaVersion parameter introduced in Groovy 4.0.27
(GROOVY-11668). This is needed because Gradle's Groovydoc task does not
expose javaVersion (gradle/gradle#33659 is not merged), causing Java 17+
source parsing failures.

Changes across all groovydoc configurations:
- gradle/docs-dependencies.gradle: central config for ~90 modules and
  both aggregate tasks (aggregateGroovydoc, aggregateDataMappingGroovydoc)
- gradle/docs-config.gradle: per-module source directory setup
- grails-doc/build.gradle: aggregate task source directories
- grails-data-docs/stage/build.gradle: data mapping aggregate source dirs
- grails-gradle/gradle/docs-config.gradle: independent AntBuilder setup
- grails-data-hibernate5/docs/build.gradle: added groovy-ant dependency
  and AntBuilder execution
- grails-data-mongodb/docs/build.gradle: added groovy-ant dependency
  and AntBuilder execution
- grails-forge/gradle/doc-config.gradle: AntBuilder without javaVersion
  (forge uses Groovy 3.0.25 which predates the feature)

Closes #15385

Assisted-by: Claude Code <Claude@Claude.ai>
…ion plugin

Move duplicated AntBuilder groovydoc execution, Matomo footer, documentation
configuration registration, and task defaults into a shared convention plugin
in build-logic. This eliminates ~490 lines of duplicated configuration across
8 build scripts while maintaining identical behavior.

The plugin provides:
- Documentation configuration registration with standard attributes
- Common Groovydoc task defaults (author, timestamps, scripts)
- AntBuilder-based execution with javaVersion support (Groovy 4.0.27+)
- Matomo analytics footer
- Source directory resolution from ext.groovydocSourceDirs or source sets
- External documentation link support via ext.groovydocLinks
- GrailsGroovydocExtension for per-project javaVersion control

Build scripts retain project-specific configuration: dependencies, titles,
source directories for aggregate tasks, and dynamic link resolution.

Assisted-by: Claude Code <Claude@Claude.ai>
Separate GrailsGroovydocPlugin into a generic GroovydocEnhancerPlugin
(with GroovydocEnhancerExtension) and a thin GrailsGroovydocPlugin that
applies the base plugin and sets the Matomo footer. This makes the core
AntBuilder groovydoc logic publishable and reusable by anyone, while
keeping Grails-specific customizations in their own layer.

The base plugin supports a useAntBuilder flag so projects can easily
switch back to Gradle's built-in Groovydoc task if Gradle merges their
javaVersion support (gradle/gradle#33659).

Also fix a pre-existing bug in resolveProjectVersion() in
docs-dependencies.gradle where the function never returned the resolved
version string, causing all external groovydoc links (geb,
testcontainers, spring, spring-boot) to be silently omitted.

Assisted-by: Claude Code <Claude@Claude.ai>
Wrap the javaVersion convention in project.provider so the property
is resolved at execution time rather than configuration time.

Assisted-by: Claude Code <Claude@Claude.ai>
Add grails-gradle-groovydoc as a published Gradle plugin module that
enables Grails applications using modern Java features (17+) to generate
accurate Groovydoc documentation. Without this plugin, Groovydoc fails
to parse Java sources using sealed classes, records, pattern matching,
and other post-Java 11 language features.

Changes:
- New module grails-gradle/groovydoc with GroovydocEnhancerPlugin
  published as org.apache.grails.gradle:grails-gradle-groovydoc
  with plugin ID org.apache.grails.gradle.groovydoc
- Forge DefaultFeature adds the plugin to all generated Grails apps
- Profile base/profile.yml applies the plugin via grails CLI generation
- grails-bom updated with the new artifact for BOM version management
- build-logic retains its own copy for the framework build (bootstrap)

Assisted-by: Claude Code <Claude@Claude.ai>
@jamesfredley
Copy link
Contributor Author

A Third "commons" build appears to be the only way to remove the duplication.

@jamesfredley
Copy link
Contributor Author

Or moving it to a separate repo, as we have done with publishing.

@jdaugherty
Copy link
Contributor

In order to publish this, its going to have to go to a separate repository...

@jamesfredley
Copy link
Contributor Author

@jdaugherty I will add that to agenda for the meeting, next week.

Base automatically changed from fix/groovydoc-java-version to 7.0.x February 26, 2026 01:23
@jamesfredley
Copy link
Contributor Author

This will either end up as a separate Apache Grails repo or possible over on Apache Groovy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants