I opened https://issues.apache.org/jira/browse/GROOVY-11668 and will take a look at submitting a pull request. Thank you.
On Sat, May 17, 2025 at 8:04 PM Paul King <pa...@asert.com.au> wrote: > A pull request would be great! > > Paul. > > > On Sun, May 18, 2025 at 2:33 AM James Daugherty < > jdaughe...@jdresources.net> wrote: > >> Hi Everyone, >> >> I am trying to modernize the Apache Grails code base since we're using >> Groovy 4.0.26 & Java 17 as a baseline. In our gradle project, we have the >> language level set to Java 17. We also have java files in our groovy >> source sets. After updating our java files to use more modern features, >> I'm getting a failure when running groovydoc. An example of this is: >> >> > Task :grails-core:groovydoc >> Attempting to ignore error parsing Java source file: >> org/grails/plugins/DefaultGrailsPlugin.java >> Consider reporting the error to the Groovy project: >> https://issues.apache.org/jira/browse/GROOVY >> ... or directly to the JavaParser project: >> https://github.com/javaparser/javaparser/issues >> Error: (line 181,col 13) Use of patterns with instanceof is not >> supported. Pay attention that this feature is supported starting from >> 'JAVA_14' language level. If you need that feature the language level must >> be configured in the configuration before parsing the source files. >> >> The cause for this error is groovydoc uses the JavaParser library and its >> default language level is set to a lower value (it currently defaults to >> the popular language level which is Java 11). If I was using this library >> directly, I would set this option to force a specific java version: >> >> >> StaticJavaParser.getConfiguration().setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_17) >> >> I searched >> https://github.com/apache/groovy/blob/master/subprojects/groovy-groovydoc >> and I don't see a level being set. I also don't see any mention of this in >> jira. Finally, I don't see any documented parameters where this can be >> set: https://groovy-lang.org/groovydoc.html >> >> Is anyone aware of how to set this language level for the existing >> groovydoc task? Would an argument to groovydoc be the preferred way to set >> this language level? If such a flag were added, I could request a gradle >> upstream change to set this flag based on the project language level. Has >> this issue been raised before? >> >> I'm happy to submit a pull request to make this change, but thought I'd >> check here first on how best to add this support or if I've missed some >> other way to set the language level. >> >> -James >> >