[ https://issues.apache.org/jira/browse/GROOVY-11668?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17952471#comment-17952471 ]
ASF GitHub Bot commented on GROOVY-11668: ----------------------------------------- Copilot commented on code in PR #2228: URL: https://github.com/apache/groovy/pull/2228#discussion_r2094629980 ########## subprojects/groovy-groovydoc/src/spec/doc/groovydoc.adoc: ########## @@ -70,8 +70,23 @@ separated by platform path separator) |-verbose| |Enable verbose output | |--version|Display the version |-windowtitle <text>| |Browser window title for the documentation +|-javaversion <version> | | The version of the Java source files |======================================================================= +=== Java Versions + +The supported Java Versions for `groovydoc` are defined by the JavaLanguageClass. The values follow the below patterns: + +- JAVA_1_0 +- JAVA_1_1 +- JAVA_1_2 +- JAVA_1_3 +- JAVA_1_4 +- JAVA_5, Review Comment: Remove the trailing comma in 'JAVA_5,' to maintain consistency with the other version entries. ```suggestion - JAVA_5 ``` ########## subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovydoc.java: ########## @@ -144,6 +147,23 @@ public void setNoVersionStamp(boolean noVersionStamp) { this.noVersionStamp = noVersionStamp; } + /** + * Defaults to a popular Java version. Otherwise, override here for a specific expected source file version. + * + * @param javaVersion the expected source level of any Java files that may be parsed + */ + public void setJavaVersion(String javaVersion) { + if(javaVersion == null) { + return; + } + + try { + this.javaVersion = JavaLanguageLevel.valueOf(javaVersion); Review Comment: Consider converting 'javaVersion' to uppercase (e.g. using javaVersion.toUpperCase()) before passing it to valueOf, to ensure consistency with the CLI parsing in Main.groovy. > Groovydoc crashes with higher Java language levels > -------------------------------------------------- > > Key: GROOVY-11668 > URL: https://issues.apache.org/jira/browse/GROOVY-11668 > Project: Groovy > Issue Type: Improvement > Components: GroovyDoc > Reporter: James Daugherty > Priority: Critical > > Groovydoc supports both groovy & java files. It supports parsing via the > JavaParser library & the library supports specifying a language level. > However, groovydoc does not have a way of setting it for the library at this > time. By default the library defaults to the "popular" language level of > that release - for the current JavaParser version that is Java 11. > As projects update to newer language features, it is desirable to continue > using groovydoc for later Java versions. This change is to add an option to > groovydoc to specify the language level based on the possible values in the > enum ParserConfiguration.LanguageLevel from the JavaParser library. -- This message was sent by Atlassian Jira (v8.20.10#820010)