diff --git a/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NBMNativeMWI.java b/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NBMNativeMWI.java index 16b3c8508079..5a7c08bc9b53 100644 --- a/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NBMNativeMWI.java +++ b/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NBMNativeMWI.java @@ -24,8 +24,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.Collections; import java.util.List; import java.util.Properties; @@ -49,6 +47,7 @@ import org.netbeans.modules.maven.model.pom.Project; import org.netbeans.modules.maven.model.pom.Repository; import org.netbeans.modules.maven.model.pom.RepositoryPolicy; +import org.netbeans.modules.maven.options.MavenVersionSettings; import org.netbeans.modules.maven.spi.newproject.CreateProjectBuilder; import org.openide.util.Exceptions; @@ -58,12 +57,12 @@ */ final class NBMNativeMWI { - static void instantiate(ProjectInfo vi, File projFile, String version, boolean useOsgi, MavenProject mp) { + static void instantiate(ProjectInfo vi, File projFile, String nbVersion, boolean useOsgi, MavenProject mp) { CreateProjectBuilder builder = new CreateProjectBuilder(projFile, vi.groupId, vi.artifactId, vi.version) .setPackageName(vi.packageName) .setPackaging("nbm") .setAdditionalNonPomWork(new AdditionalFiles()) - .setAdditionalOperations(new AdditionalOperations(version, useOsgi)); + .setAdditionalOperations(new AdditionalOperations(nbVersion, useOsgi)); if (mp != null) { builder = builder.setParentProject(mp); } @@ -237,7 +236,6 @@ public void performOperation(POMModel model) { //nbm-maven-plugin boolean addPlugin = true; String managedPVersion = null; - String pVersion = MavenNbModuleImpl.getLatestNbmPluginVersion(); // boolean useOsgiDepsSet = false; if (parent != null) { //TODO do we want to support the case when the plugin is defined in parent pom with inherited=true? @@ -259,12 +257,13 @@ public void performOperation(POMModel model) { } } } + MavenVersionSettings settings = MavenVersionSettings.getDefault(); if (addPlugin) { Plugin p = model.getFactory().createPlugin(); p.setGroupId(MavenNbModuleImpl.GROUPID_APACHE); p.setArtifactId(MavenNbModuleImpl.NBM_PLUGIN); if (managedPVersion == null) { - p.setVersion(pVersion); + p.setVersion(MavenNbModuleImpl.getLatestNbmPluginVersion()); } p.setExtensions(true); if (useOsgi) { @@ -278,52 +277,44 @@ public void performOperation(POMModel model) { //now comes the compiler plugin addPlugin = true; managedPVersion = null; - String source = null; - String target = null; - pVersion = "3.11.0"; if (parent != null) { //TODO do we want to support the case when the plugin is defined in parent pom with inherited=true? PluginManagement pm = parent.getPluginManagement(); if (pm != null) { - for (org.apache.maven.model.Plugin p : pm.getPlugins()) { - if (Constants.GROUP_APACHE_PLUGINS.equals(p.getGroupId()) && Constants.PLUGIN_COMPILER.equals(p.getArtifactId())) { - managedPVersion = p.getVersion(); - Xpp3Dom conf = (Xpp3Dom) p.getConfiguration(); - if (conf != null) { - Xpp3Dom sourceEl = conf.getChild("source"); - if (sourceEl != null) { - source = sourceEl.getValue(); - } - Xpp3Dom targetEl = conf.getChild("target"); - if (targetEl != null) { - target = targetEl.getValue(); + if (parent.getProperties().getProperty("maven.compiler.release") != null) { + addPlugin = false; + } else { + for (org.apache.maven.model.Plugin p : pm.getPlugins()) { + if (Constants.GROUP_APACHE_PLUGINS.equals(p.getGroupId()) && Constants.PLUGIN_COMPILER.equals(p.getArtifactId())) { + managedPVersion = p.getVersion(); + Xpp3Dom conf = (Xpp3Dom) p.getConfiguration(); + if (conf != null) { + if ( conf.getChild("release") != null + || conf.getChild("source") != null + || conf.getChild("target") != null) { + addPlugin = false; + } } + break; } - break; } } } } - addPlugin = target == null || source == null; if (addPlugin) { Plugin p = model.getFactory().createPlugin(); p.setGroupId(Constants.GROUP_APACHE_PLUGINS); p.setArtifactId(Constants.PLUGIN_COMPILER); if (managedPVersion == null) { - p.setVersion(pVersion); + p.setVersion(settings.getVersion(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER)); } - Configuration c = model.getFactory().createConfiguration(); - c.setSimpleParameter("source", "1.8"); - c.setSimpleParameter("target", "1.8"); - p.setConfiguration(c); getOrCreateBuild(model).addPlugin(p); + model.getProject().getProperties().setProperty("maven.compiler.release", "17"); } //now the jar plugin - addPlugin = true; managedPVersion = null; String useManifest = null; - pVersion = "3.3.0"; if (parent != null) { //TODO do we want to support the case when the plugin is defined in parent pom with inherited=true? PluginManagement pm = parent.getPluginManagement(); @@ -359,6 +350,7 @@ public void performOperation(POMModel model) { p.setGroupId(Constants.GROUP_APACHE_PLUGINS); p.setArtifactId(Constants.PLUGIN_JAR); if (managedPVersion == null) { + String pVersion = settings.getVersion(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_JAR); p.setVersion(pVersion); managedPVersion = pVersion; } diff --git a/apisupport/maven.apisupport/test/unit/src/org/netbeans/modules/maven/apisupport/NBMNativeMWITest.java b/apisupport/maven.apisupport/test/unit/src/org/netbeans/modules/maven/apisupport/NBMNativeMWITest.java index 869fe7a1b20a..2fa9e7aa1c21 100644 --- a/apisupport/maven.apisupport/test/unit/src/org/netbeans/modules/maven/apisupport/NBMNativeMWITest.java +++ b/apisupport/maven.apisupport/test/unit/src/org/netbeans/modules/maven/apisupport/NBMNativeMWITest.java @@ -38,6 +38,8 @@ public class NBMNativeMWITest extends NbTestCase { + private static final String EXPECTED_JAVAC_PLUGIN_VERSION = "3.13.0"; + private FileObject wd; public NBMNativeMWITest(String testName) { @@ -64,7 +66,7 @@ public void testPathNoParent() throws IOException, XmlPullParserException { assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId()); assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion()); assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId()); - assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion()); + assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion()); assertEquals(0, model.getRepositories().size()); } @@ -82,7 +84,7 @@ public void testPathNoParentSnapshot() throws IOException, XmlPullParserExceptio assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId()); assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion()); assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId()); - assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion()); + assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion()); assertEquals(1, model.getRepositories().size()); } @@ -109,7 +111,7 @@ public void testPathParent() throws IOException, XmlPullParserException { assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId()); assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion()); assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId()); - assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion()); + assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion()); assertEquals(0, model.getRepositories().size()); } @@ -135,7 +137,7 @@ public void testPathParentSnapshot() throws IOException, XmlPullParserException assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId()); assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion()); assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId()); - assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion()); + assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion()); assertEquals(1, model.getRepositories().size()); } @@ -190,7 +192,7 @@ public void testPathParentJar() throws IOException, XmlPullParserException { assertEquals("nbm-maven-plugin", modeloutput.getBuild().getPlugins().get(0).getArtifactId()); assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), modeloutput.getBuild().getPlugins().get(0).getVersion()); assertEquals("maven-compiler-plugin", modeloutput.getBuild().getPlugins().get(1).getArtifactId()); - assertEquals("3.11.0", modeloutput.getBuild().getPlugins().get(1).getVersion()); + assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, modeloutput.getBuild().getPlugins().get(1).getVersion()); assertEquals(0, model.getRepositories().size()); } diff --git a/java/maven/src/org/netbeans/modules/maven/options/MavenVersionSettings.java b/java/maven/src/org/netbeans/modules/maven/options/MavenVersionSettings.java index 6ca94706a6fe..5f1e41c1752c 100644 --- a/java/maven/src/org/netbeans/modules/maven/options/MavenVersionSettings.java +++ b/java/maven/src/org/netbeans/modules/maven/options/MavenVersionSettings.java @@ -44,11 +44,12 @@ public final class MavenVersionSettings { static { // TODO update periodically - modifications might require unit test adjustments - String nb_version = "RELEASE220"; - String nb_utilities_version = "14.1"; + String nb_version = "RELEASE230"; + String nb_utilities_version = "14.2"; fallback = Map.ofEntries( entry(key("org.netbeans.api", "org-netbeans-modules-editor"), nb_version), // represents all other nb artifacts entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER), "3.13.0"), + entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_JAR), "3.4.2"), entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_RESOURCES), "3.3.1"), entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_FAILSAFE), "3.3.1"), entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_SUREFIRE), "3.3.1"), @@ -57,8 +58,8 @@ public final class MavenVersionSettings { entry(key("org.apache.netbeans.utilities", "nbm-shared"), nb_utilities_version), entry(key("org.apache.netbeans.utilities", "nbm-repository-plugin"), nb_utilities_version), entry(key("org.apache.netbeans.utilities", "nbm-maven-plugin"), nb_utilities_version), - entry(key("org.apache.netbeans.archetypes", "nbm-archetype"), "1.18"), - entry(key("org.apache.netbeans.archetypes", "netbeans-platform-app-archetype"), "1.23") + entry(key("org.apache.netbeans.archetypes", "nbm-archetype"), "1.19"), + entry(key("org.apache.netbeans.archetypes", "netbeans-platform-app-archetype"), "1.24") ); }