Yes, Gradle doesn't know about those 4.0.27 changes yet. Feel free to
pester them to add that in an upcoming Gradle release.

For now, you can create a custom groovy task, sort of like where
Grails is possibly headed:

https://github.com/apache/grails-core/blob/groovydoc-tool-rewrite/buildSrc/src/main/groovy/org/apache/grails/internal/build/GrailsGroovydocWorker.groovy

Or, just call the commandline or Ant task making sure that Groovy
4.0.27 (groovy, groovy-groovydoc, groovy-ant if using ant) is on the
classpath:

tasks.register('runGroovyDoc', JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    mainClass = 'org.codehaus.groovy.tools.groovydoc.Main'
    args = ['-d', 'build/groovydoc', '-sourcepath',
sourceSets.main.groovy.srcDirs.join(':'), '-javaVersion', 'JAVA_17',
'.']
}

tasks.register('runGroovyDocAnt') {
    doLast {
        ant.taskdef(name: 'groovydoc', classname:
'org.codehaus.groovy.ant.Groovydoc', classpath:
sourceSets.main.runtimeClasspath.asPath)
        ant.groovydoc(
            destdir: 'build/groovydocant',
            sourcepath: sourceSets.main.groovy.srcDirs.join(':'),
            packagenames: '*',
            javaVersion: 'JAVA_17') {
        }
    }
}


Cheers,
Paul.

On Thu, May 29, 2025 at 5:07 AM Per Nyfelt <p...@alipsa.se> wrote:
>
> Hi,
>
> I am keen to use the new javaVersion property added to GroovyDoc in 4.0.27 
> but cannot figure it out. According to the gradle documentation, "The version 
> of the Groovydoc that is used, is the one from the Groovy dependency defined 
> in the build script." so i did this:
>
> add implementation `"org.apache.groovy:groovy-ant:4.0.27"` to dependencies
>
> add a groovydoc config
>
> groovydoc {
>     docTitle = "${project.name} ${project.version}"
>     windowTitle = "${project.name} ${project.version}"
>     link 'https://docs.oracle.com/en/java/javase/21/docs/api/', 'java.'
>     javaVersion = 'JAVA_21'
> }
>
> But gradle is unhappy with this:
>
> > Could not set unknown property 'javaVersion' for task 
> > ':matrix-spreadsheet:groovydoc' of type 
> > org.gradle.api.tasks.javadoc.Groovydoc.
>
> Has anyone got this to work and could share some insights?
>
>

Reply via email to