This is an automated email from the ASF dual-hosted git repository. mbien pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new af8032df0d Prevent NPE inside enable preview for Maven when pom.xml contains the build section, but the compiler plugin is not registered. new 80e6f98352 Merge pull request #6446 from lahodaj/fix-enable-preview-maven af8032df0d is described below commit af8032df0de3345cb1fecb806192a3fb56730a7a Author: Jan Lahoda <jan.lah...@oracle.com> AuthorDate: Thu Sep 14 10:53:03 2023 +0200 Prevent NPE inside enable preview for Maven when pom.xml contains the build section, but the compiler plugin is not registered. --- .../maven/hints/errors/EnablePreviewMavenProj.java | 3 +- .../hints/errors/EnablePreviewMavenProjTest.java | 51 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/java/maven.hints/src/org/netbeans/modules/maven/hints/errors/EnablePreviewMavenProj.java b/java/maven.hints/src/org/netbeans/modules/maven/hints/errors/EnablePreviewMavenProj.java index e06c46c9a0..9b963221ab 100644 --- a/java/maven.hints/src/org/netbeans/modules/maven/hints/errors/EnablePreviewMavenProj.java +++ b/java/maven.hints/src/org/netbeans/modules/maven/hints/errors/EnablePreviewMavenProj.java @@ -343,7 +343,8 @@ public class EnablePreviewMavenProj implements PreviewEnabler { @Override public void performOperation(final POMModel model) { Build build = model.getProject().getBuild(); - Plugin plugin = build != null ? searchMavenCompilerPlugin(build).second() : null; + Pair<PluginContainer, Plugin> containerAndPlugin = build != null ? searchMavenCompilerPlugin(build) : null; + Plugin plugin = containerAndPlugin != null ? containerAndPlugin.second() : null; Configuration configuration = plugin != null ? plugin.getConfiguration() : null; if (configuration != null) { diff --git a/java/maven.hints/test/unit/src/org/netbeans/modules/maven/hints/errors/EnablePreviewMavenProjTest.java b/java/maven.hints/test/unit/src/org/netbeans/modules/maven/hints/errors/EnablePreviewMavenProjTest.java index f65dd7cf19..a0904c04b0 100644 --- a/java/maven.hints/test/unit/src/org/netbeans/modules/maven/hints/errors/EnablePreviewMavenProjTest.java +++ b/java/maven.hints/test/unit/src/org/netbeans/modules/maven/hints/errors/EnablePreviewMavenProjTest.java @@ -916,6 +916,57 @@ public class EnablePreviewMavenProjTest extends NbTestCase { "</project>"); } + public void testHasBuildButNotCompilerPlugin() throws Exception { + runTest("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n" + + " <modelVersion>4.0.0</modelVersion>\n" + + " <groupId>test</groupId>\n" + + " <artifactId>mavenproject1</artifactId>\n" + + " <version>1.0-SNAPSHOT</version>\n" + + " <packaging>jar</packaging>\n" + + " <build>\n" + + " <plugins>\n" + + " <plugin>\n" + + " <groupId>org.apache.maven.plugins</groupId>\n" + + " <artifactId>maven-surefire-plugin</artifactId>\n" + + " <version>3.1.0</version>\n" + + " </plugin>\n" + + " </plugins>\n" + + " </build>\n" + + "</project>", + "21", + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n" + + " <modelVersion>4.0.0</modelVersion>\n" + + " <groupId>test</groupId>\n" + + " <artifactId>mavenproject1</artifactId>\n" + + " <version>1.0-SNAPSHOT</version>\n" + + " <packaging>jar</packaging>\n" + + " <build>\n" + + " <plugins>\n" + + " <plugin>\n" + + " <groupId>org.apache.maven.plugins</groupId>\n" + + " <artifactId>maven-surefire-plugin</artifactId>\n" + + " <version>3.1.0</version>\n" + + " </plugin>\n" + + " <plugin>\n" + + " <groupId>org.apache.maven.plugins</groupId>\n" + + " <artifactId>maven-compiler-plugin</artifactId>\n" + + " <version>3.11.0</version>\n" + + " <configuration>\n" + + " <compilerArgs>\n" + + " <arg>--enable-preview</arg>\n" + + " </compilerArgs>\n" + + " </configuration>\n" + + " </plugin>\n" + + " </plugins>\n" + + " </build>\n" + + " <properties>\n" + + " <maven.compiler.release>21</maven.compiler.release>\n" + + " </properties>\n" + + "</project>"); + } + private void runTest(String original, String newSL, String expected) throws Exception { runTest(original, newSL, expected, true); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists