Re: Using javaVersion for groovydoc in 4.0.27

Per Nyfelt <[email protected]> Thu, 29 May 2025 10:13:11 +0200
Newsgroups gmane.comp.lang.groovy.user
Organization Alipsa HB
Message-ID <[email protected]>
Great, thanks Paul! The workaround using ant directly in gradle works fine!

I created a feature request to support the javaVersion property to the 
gradle team here https://github.com/gradle/gradle/issues/33659.

Best regards,

Per

On 5/29/25 08:52, Paul King wrote:
> 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 <[email protected]> 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?
>>
>>