[ https://issues.apache.org/jira/browse/GROOVY-11668?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17952678#comment-17952678 ]
ASF GitHub Bot commented on GROOVY-11668: ----------------------------------------- jdaugherty commented on code in PR #2228: URL: https://github.com/apache/groovy/pull/2228#discussion_r2096097956 ########## subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocTest.java: ########## @@ -84,6 +85,43 @@ public void testCustomClassTemplate() throws Exception { assertTrue("\"This is a custom class template.\" not in: " + lines, lines.contains("This is a custom class template.")); } + @Test + public void testSupportedJavadocVersion() throws Exception { + rule.executeTarget("supportedGroovyDocJava"); + + final File testfilesPackageDir = new File(tmpDir, "org/codehaus/groovy/tools/groovydoc/testfiles/generics"); + final String[] list = testfilesPackageDir.list((file, name) -> name.equals("Java.html")); + + assertNotNull("Dir not found: " + testfilesPackageDir.getAbsolutePath(), list); + assertEquals(1, list.length); + File documentedClass = new File(testfilesPackageDir, list[0]); + assertTrue("Java.html not found: " + documentedClass.getAbsolutePath(), documentedClass.exists()); + + List<String> lines = ResourceGroovyMethods.readLines(documentedClass); + assertTrue("\"<title>Java</title>\" not in: " + lines, lines.contains("<title>Java</title>")); + } + + @Test + public void testUnsupportedJavadocVersion() throws Exception { + rule.executeTarget("unsupportedGroovyDocJava"); + + final File testfilesPackageDir = new File(tmpDir, "org/codehaus/groovy/tools/groovydoc/testfiles/generics"); + final String[] list = testfilesPackageDir.list((file, name) -> name.equals("Java.html")); + + assertNotNull("Dir not found: " + testfilesPackageDir.getAbsolutePath(), list); + assertEquals("Files unexpectedly found when not expecting to parse",0, list.length); + } + + @Test + public void testInvalidJavaVersion() throws Exception { + try { + rule.executeTarget("invalidJavaVersion"); + } + catch(BuildException e) { + assertEquals("java.lang.IllegalArgumentException: Unsupported Java Version: DNE", e.getMessage()); Review Comment: This isn't valid (the test passes) > 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)