Skip to content

Commit be2a72c

Browse files
authored
Merge pull request #7628 from mbien/nbm-wizard-version-fixes_delivery
Minor NBM wizard pom generation fixes and plugin version bumps
2 parents fd8c7ae + 4f80c4d commit be2a72c

File tree

3 files changed

+34
-39
lines changed

3 files changed

+34
-39
lines changed

apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NBMNativeMWI.java

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import java.io.FileOutputStream;
2525
import java.io.IOException;
2626
import java.io.OutputStream;
27-
import java.nio.file.Files;
28-
import java.nio.file.Path;
2927
import java.util.Collections;
3028
import java.util.List;
3129
import java.util.Properties;
@@ -49,6 +47,7 @@
4947
import org.netbeans.modules.maven.model.pom.Project;
5048
import org.netbeans.modules.maven.model.pom.Repository;
5149
import org.netbeans.modules.maven.model.pom.RepositoryPolicy;
50+
import org.netbeans.modules.maven.options.MavenVersionSettings;
5251
import org.netbeans.modules.maven.spi.newproject.CreateProjectBuilder;
5352
import org.openide.util.Exceptions;
5453

@@ -58,12 +57,12 @@
5857
*/
5958
final class NBMNativeMWI {
6059

61-
static void instantiate(ProjectInfo vi, File projFile, String version, boolean useOsgi, MavenProject mp) {
60+
static void instantiate(ProjectInfo vi, File projFile, String nbVersion, boolean useOsgi, MavenProject mp) {
6261
CreateProjectBuilder builder = new CreateProjectBuilder(projFile, vi.groupId, vi.artifactId, vi.version)
6362
.setPackageName(vi.packageName)
6463
.setPackaging("nbm")
6564
.setAdditionalNonPomWork(new AdditionalFiles())
66-
.setAdditionalOperations(new AdditionalOperations(version, useOsgi));
65+
.setAdditionalOperations(new AdditionalOperations(nbVersion, useOsgi));
6766
if (mp != null) {
6867
builder = builder.setParentProject(mp);
6968
}
@@ -237,7 +236,6 @@ public void performOperation(POMModel model) {
237236
//nbm-maven-plugin
238237
boolean addPlugin = true;
239238
String managedPVersion = null;
240-
String pVersion = MavenNbModuleImpl.getLatestNbmPluginVersion();
241239
// boolean useOsgiDepsSet = false;
242240
if (parent != null) {
243241
//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) {
259257
}
260258
}
261259
}
260+
MavenVersionSettings settings = MavenVersionSettings.getDefault();
262261
if (addPlugin) {
263262
Plugin p = model.getFactory().createPlugin();
264263
p.setGroupId(MavenNbModuleImpl.GROUPID_APACHE);
265264
p.setArtifactId(MavenNbModuleImpl.NBM_PLUGIN);
266265
if (managedPVersion == null) {
267-
p.setVersion(pVersion);
266+
p.setVersion(MavenNbModuleImpl.getLatestNbmPluginVersion());
268267
}
269268
p.setExtensions(true);
270269
if (useOsgi) {
@@ -278,52 +277,44 @@ public void performOperation(POMModel model) {
278277
//now comes the compiler plugin
279278
addPlugin = true;
280279
managedPVersion = null;
281-
String source = null;
282-
String target = null;
283-
pVersion = "3.11.0";
284280
if (parent != null) {
285281
//TODO do we want to support the case when the plugin is defined in parent pom with inherited=true?
286282
PluginManagement pm = parent.getPluginManagement();
287283
if (pm != null) {
288-
for (org.apache.maven.model.Plugin p : pm.getPlugins()) {
289-
if (Constants.GROUP_APACHE_PLUGINS.equals(p.getGroupId()) && Constants.PLUGIN_COMPILER.equals(p.getArtifactId())) {
290-
managedPVersion = p.getVersion();
291-
Xpp3Dom conf = (Xpp3Dom) p.getConfiguration();
292-
if (conf != null) {
293-
Xpp3Dom sourceEl = conf.getChild("source");
294-
if (sourceEl != null) {
295-
source = sourceEl.getValue();
296-
}
297-
Xpp3Dom targetEl = conf.getChild("target");
298-
if (targetEl != null) {
299-
target = targetEl.getValue();
284+
if (parent.getProperties().getProperty("maven.compiler.release") != null) {
285+
addPlugin = false;
286+
} else {
287+
for (org.apache.maven.model.Plugin p : pm.getPlugins()) {
288+
if (Constants.GROUP_APACHE_PLUGINS.equals(p.getGroupId()) && Constants.PLUGIN_COMPILER.equals(p.getArtifactId())) {
289+
managedPVersion = p.getVersion();
290+
Xpp3Dom conf = (Xpp3Dom) p.getConfiguration();
291+
if (conf != null) {
292+
if ( conf.getChild("release") != null
293+
|| conf.getChild("source") != null
294+
|| conf.getChild("target") != null) {
295+
addPlugin = false;
296+
}
300297
}
298+
break;
301299
}
302-
break;
303300
}
304301
}
305302
}
306303
}
307-
addPlugin = target == null || source == null;
308304
if (addPlugin) {
309305
Plugin p = model.getFactory().createPlugin();
310306
p.setGroupId(Constants.GROUP_APACHE_PLUGINS);
311307
p.setArtifactId(Constants.PLUGIN_COMPILER);
312308
if (managedPVersion == null) {
313-
p.setVersion(pVersion);
309+
p.setVersion(settings.getVersion(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER));
314310
}
315-
Configuration c = model.getFactory().createConfiguration();
316-
c.setSimpleParameter("source", "1.8");
317-
c.setSimpleParameter("target", "1.8");
318-
p.setConfiguration(c);
319311
getOrCreateBuild(model).addPlugin(p);
312+
model.getProject().getProperties().setProperty("maven.compiler.release", "17");
320313
}
321314

322315
//now the jar plugin
323-
addPlugin = true;
324316
managedPVersion = null;
325317
String useManifest = null;
326-
pVersion = "3.3.0";
327318
if (parent != null) {
328319
//TODO do we want to support the case when the plugin is defined in parent pom with inherited=true?
329320
PluginManagement pm = parent.getPluginManagement();
@@ -359,6 +350,7 @@ public void performOperation(POMModel model) {
359350
p.setGroupId(Constants.GROUP_APACHE_PLUGINS);
360351
p.setArtifactId(Constants.PLUGIN_JAR);
361352
if (managedPVersion == null) {
353+
String pVersion = settings.getVersion(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_JAR);
362354
p.setVersion(pVersion);
363355
managedPVersion = pVersion;
364356
}

apisupport/maven.apisupport/test/unit/src/org/netbeans/modules/maven/apisupport/NBMNativeMWITest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
public class NBMNativeMWITest extends NbTestCase {
4040

41+
private static final String EXPECTED_JAVAC_PLUGIN_VERSION = "3.13.0";
42+
4143
private FileObject wd;
4244

4345
public NBMNativeMWITest(String testName) {
@@ -64,7 +66,7 @@ public void testPathNoParent() throws IOException, XmlPullParserException {
6466
assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId());
6567
assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion());
6668
assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId());
67-
assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion());
69+
assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion());
6870
assertEquals(0, model.getRepositories().size());
6971
}
7072

@@ -82,7 +84,7 @@ public void testPathNoParentSnapshot() throws IOException, XmlPullParserExceptio
8284
assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId());
8385
assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion());
8486
assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId());
85-
assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion());
87+
assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion());
8688
assertEquals(1, model.getRepositories().size());
8789
}
8890

@@ -109,7 +111,7 @@ public void testPathParent() throws IOException, XmlPullParserException {
109111
assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId());
110112
assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion());
111113
assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId());
112-
assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion());
114+
assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion());
113115
assertEquals(0, model.getRepositories().size());
114116
}
115117

@@ -135,7 +137,7 @@ public void testPathParentSnapshot() throws IOException, XmlPullParserException
135137
assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId());
136138
assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion());
137139
assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId());
138-
assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion());
140+
assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion());
139141
assertEquals(1, model.getRepositories().size());
140142
}
141143

@@ -190,7 +192,7 @@ public void testPathParentJar() throws IOException, XmlPullParserException {
190192
assertEquals("nbm-maven-plugin", modeloutput.getBuild().getPlugins().get(0).getArtifactId());
191193
assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), modeloutput.getBuild().getPlugins().get(0).getVersion());
192194
assertEquals("maven-compiler-plugin", modeloutput.getBuild().getPlugins().get(1).getArtifactId());
193-
assertEquals("3.11.0", modeloutput.getBuild().getPlugins().get(1).getVersion());
195+
assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, modeloutput.getBuild().getPlugins().get(1).getVersion());
194196
assertEquals(0, model.getRepositories().size());
195197
}
196198

java/maven/src/org/netbeans/modules/maven/options/MavenVersionSettings.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ public final class MavenVersionSettings {
4444

4545
static {
4646
// TODO update periodically - modifications might require unit test adjustments
47-
String nb_version = "RELEASE220";
48-
String nb_utilities_version = "14.1";
47+
String nb_version = "RELEASE230";
48+
String nb_utilities_version = "14.2";
4949
fallback = Map.ofEntries(
5050
entry(key("org.netbeans.api", "org-netbeans-modules-editor"), nb_version), // represents all other nb artifacts
5151
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER), "3.13.0"),
52+
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_JAR), "3.4.2"),
5253
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_RESOURCES), "3.3.1"),
5354
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_FAILSAFE), "3.3.1"),
5455
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_SUREFIRE), "3.3.1"),
@@ -57,8 +58,8 @@ public final class MavenVersionSettings {
5758
entry(key("org.apache.netbeans.utilities", "nbm-shared"), nb_utilities_version),
5859
entry(key("org.apache.netbeans.utilities", "nbm-repository-plugin"), nb_utilities_version),
5960
entry(key("org.apache.netbeans.utilities", "nbm-maven-plugin"), nb_utilities_version),
60-
entry(key("org.apache.netbeans.archetypes", "nbm-archetype"), "1.18"),
61-
entry(key("org.apache.netbeans.archetypes", "netbeans-platform-app-archetype"), "1.23")
61+
entry(key("org.apache.netbeans.archetypes", "nbm-archetype"), "1.19"),
62+
entry(key("org.apache.netbeans.archetypes", "netbeans-platform-app-archetype"), "1.24")
6263
);
6364
}
6465

0 commit comments

Comments
 (0)