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 2e25ab547b nb project wizard fixes
new 68b7bb7f14 Merge pull request #4357 from mbien/nbm-project-wizard-fixes
2e25ab547b is described below
commit 2e25ab547bb0bdf989eec3aee7db2bbe4f0ab472
Author: Michael Bien <[email protected]>
AuthorDate: Sat Jul 9 21:24:41 2022 +0200
nb project wizard fixes
- don't add osgi flag if it was not checked (followup on #4007)
- upgrade nbm-plugin version in nb app project wizard (fixes #4316)
(nbm project did already upgrade it correctly)
- minor cleanup
---
.../maven/apisupport/NbmWizardIterator.java | 115 +++++++++++----------
.../maven/apisupport/NbmWizardPanelVisual.form | 2 -
.../maven/apisupport/NbmWizardPanelVisual.java | 13 +--
3 files changed, 64 insertions(+), 66 deletions(-)
diff --git
a/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
b/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
index 12bd22f9a9..b635c0a6d2 100644
---
a/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
+++
b/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
@@ -53,6 +53,8 @@ import static
org.netbeans.modules.maven.apisupport.MavenNbModuleImpl.APACHE_SNA
import org.netbeans.modules.maven.embedder.EmbedderFactory;
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
+import org.netbeans.modules.maven.model.pom.Plugin;
+import org.netbeans.modules.maven.model.pom.PluginManagement;
import org.netbeans.spi.project.ui.support.CommonProjectActions;
public class NbmWizardIterator implements
WizardDescriptor.BackgroundInstantiatingIterator<WizardDescriptor> {
@@ -147,49 +149,60 @@ public class NbmWizardIterator implements
WizardDescriptor.BackgroundInstantiati
NBMNativeMWI.instantiate(vi, projFile, version,
Boolean.TRUE.equals(wiz.getProperty(OSGIDEPENDENCIES)), null);
} else {
- getLatestArchetypeVersion(NB_APP_ARCH);
- ArchetypeWizards.createFromArchetype(projFile, vi, archetype,
additional, true);
- List<ModelOperation<POMModel>> opers = new
ArrayList<ModelOperation<POMModel>>();
- if (Boolean.TRUE.equals(wiz.getProperty(OSGIDEPENDENCIES))) {
- //now we have the nbm-archetype (or the netbeans platform one).
- ModelOperation<POMModel> osgi =
addNbmPluginOsgiParameter(projFile);
- if (osgi != null) {
- opers.add(osgi);
+ getLatestArchetypeVersion(NB_APP_ARCH);
+ ArchetypeWizards.createFromArchetype(projFile, vi, archetype,
additional, true);
+ List<ModelOperation<POMModel>> opers = new ArrayList<>();
+ if (Boolean.TRUE.equals(wiz.getProperty(OSGIDEPENDENCIES))) {
+ //now we have the nbm-archetype (or the netbeans platform
one).
+ ModelOperation<POMModel> osgi =
addNbmPluginOsgiParameter(projFile);
+ if (osgi != null) {
+ opers.add(osgi);
+ }
}
- }
- if (SNAPSHOT_VERSION.equals(version)) { // NOI18N
- opers.add(addSnapshotRepo());
- }
- if (!opers.isEmpty()) {
- FileObject prjDir = FileUtil.toFileObject(projFile);
- if (prjDir != null) {
- FileObject pom = prjDir.getFileObject("pom.xml");
- if (pom != null) {
- Project prj =
ProjectManager.getDefault().findProject(prjDir);
- if (prj != null) {
- Utilities.performPOMModelOperations(pom, opers);
+ if (SNAPSHOT_VERSION.equals(version)) { // NOI18N
+ opers.add(addSnapshotRepo());
+ }
+
+ // upgrade nbm plugin version to latest
+ opers.add((ModelOperation<POMModel>) (POMModel model) -> {
+ org.netbeans.modules.maven.model.pom.Project project =
model.getProject();
+ PluginManagement pm =
project.getBuild().getPluginManagement();
+ if (pm != null) {
+ Plugin plg =
PluginBackwardPropertyUtils.findPluginFromPluginManagement(pm);
+
plg.setVersion(MavenNbModuleImpl.getLatestNbmPluginVersion());
+ }
+ });
+
+ if (!opers.isEmpty()) {
+ FileObject prjDir = FileUtil.toFileObject(projFile);
+ if (prjDir != null) {
+ FileObject pom = prjDir.getFileObject("pom.xml");
+ if (pom != null) {
+ Project prj =
ProjectManager.getDefault().findProject(prjDir);
+ if (prj != null) {
+ Utilities.performPOMModelOperations(pom, opers);
+ }
}
}
}
- }
-
- if (nbm_artifactId != null && projFile.exists()) {
- //NOW we have the nbm-Platform or nbm suite template
- //create the nbm module
-
- //a bit of a hack, the archetype + modified parent project has
not reloaded yet properly
- Project p =
ProjectManager.getDefault().findProject(FileUtil.toFileObject(projFile));
- MavenProject mp =
p.getLookup().lookup(NbMavenProject.class).loadAlternateMavenProject(EmbedderFactory.getProjectEmbedder(),
Collections.<String>emptyList(), null);
-
- ProjectInfo nbm = new ProjectInfo(vi.groupId, nbm_artifactId,
vi.version, vi.packageName);
- File nbm_folder = FileUtil.normalizeFile(new File(projFile,
nbm_artifactId));
- NBMNativeMWI.instantiate(nbm, nbm_folder, version,
Boolean.TRUE.equals(wiz.getProperty(OSGIDEPENDENCIES)), mp);
- if (archetype == NB_APP_ARCH) {
- File appDir = new File(projFile, "application"); //NOI18N
- addModuleToApplication(appDir, new
ProjectInfo("${project.groupId}", nbm.artifactId, "${project.version}",
nbm.packageName), null); // NOI18N
+
+ if (nbm_artifactId != null && projFile.exists()) {
+ //NOW we have the nbm-Platform or nbm suite template
+ //create the nbm module
+
+ //a bit of a hack, the archetype + modified parent project
has not reloaded yet properly
+ Project p =
ProjectManager.getDefault().findProject(FileUtil.toFileObject(projFile));
+ MavenProject mp =
p.getLookup().lookup(NbMavenProject.class).loadAlternateMavenProject(EmbedderFactory.getProjectEmbedder(),
Collections.<String>emptyList(), null);
+
+ ProjectInfo nbm = new ProjectInfo(vi.groupId,
nbm_artifactId, vi.version, vi.packageName);
+ File nbm_folder = FileUtil.normalizeFile(new
File(projFile, nbm_artifactId));
+ NBMNativeMWI.instantiate(nbm, nbm_folder, version,
Boolean.TRUE.equals(wiz.getProperty(OSGIDEPENDENCIES)), mp);
+ if (archetype == NB_APP_ARCH) {
+ File appDir = new File(projFile, "application");
//NOI18N
+ addModuleToApplication(appDir, new
ProjectInfo("${project.groupId}", nbm.artifactId, "${project.version}",
nbm.packageName), null); // NOI18N
+ }
}
}
- }
//TODO what is this supposed to do?
Set<FileObject> projects = ArchetypeWizards.openProjects(projFile,
new File(projFile, "application"));
@@ -303,20 +316,18 @@ public class NbmWizardIterator implements
WizardDescriptor.BackgroundInstantiati
}
private static ModelOperation<POMModel> addSnapshotRepo() throws
IOException {
- return new ModelOperation<POMModel>() {
- public @Override void performOperation(POMModel model) {
- Repository repo =
model.getFactory().createRepository();
- repo.setId(APACHE_SNAPSHOT_REPO_ID); // NOI18N
- repo.setName("Apache Development Snapshot
Repository"); // NOI18N
- /* Is the following necessary?
- RepositoryPolicy policy =
model.getFactory().createSnapshotRepositoryPolicy();
- policy.setEnabled(true);
- repo.setSnapshots(policy);
- */
-
repo.setUrl("https://repository.apache.org/content/repositories/snapshots/");
// NOI18N
- model.getProject().addRepository(repo);
- }
- };
+ return (POMModel model) -> {
+ Repository repo = model.getFactory().createRepository();
+ repo.setId(APACHE_SNAPSHOT_REPO_ID); // NOI18N
+ repo.setName("Apache Development Snapshot Repository"); // NOI18N
+ /* Is the following necessary?
+ RepositoryPolicy policy =
model.getFactory().createSnapshotRepositoryPolicy();
+ policy.setEnabled(true);
+ repo.setSnapshots(policy);
+ */
+
repo.setUrl("https://repository.apache.org/content/repositories/snapshots/");
// NOI18N
+ model.getProject().addRepository(repo);
+ };
}
private static void addModuleToApplication(File file, ProjectInfo nbm,
Object object) {
@@ -324,7 +335,7 @@ public class NbmWizardIterator implements
WizardDescriptor.BackgroundInstantiati
if (appPrjFO == null) {
return;
}
- List<ModelOperation<POMModel>> operations = new
ArrayList<ModelOperation<POMModel>>();
+ List<ModelOperation<POMModel>> operations = new ArrayList<>();
operations.add(ArchetypeWizards.addDependencyOperation(nbm, null));
Utilities.performPOMModelOperations(appPrjFO.getFileObject("pom.xml"),
operations);
}
diff --git
a/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.form
b/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.form
index c4f0093234..e06de7c9cb 100644
---
a/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.form
+++
b/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.form
@@ -120,11 +120,9 @@
</Component>
<Component class="javax.swing.JCheckBox" name="cbOsgiDeps">
<Properties>
- <Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String"
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString
bundle="org/netbeans/modules/maven/apisupport/Bundle.properties"
key="NbmWizardPanelVisual.cbOsgiDeps.text"
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class,
"{key}")"/>
</Property>
- <Property name="enabled" type="boolean" value="false"/>
</Properties>
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleDescription"
type="java.lang.String"
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
diff --git
a/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
b/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
index f3ea6c1021..df4eaca110 100644
---
a/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
+++
b/apisupport/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
@@ -205,9 +205,7 @@ public class NbmWizardPanelVisual extends
javax.swing.JPanel {
}
});
- cbOsgiDeps.setSelected(true);
org.openide.awt.Mnemonics.setLocalizedText(cbOsgiDeps,
org.openide.util.NbBundle.getMessage(NbmWizardPanelVisual.class,
"NbmWizardPanelVisual.cbOsgiDeps.text")); // NOI18N
- cbOsgiDeps.setEnabled(false);
cbAddModule.setSelected(true);
org.openide.awt.Mnemonics.setLocalizedText(cbAddModule,
org.openide.util.NbBundle.getMessage(NbmWizardPanelVisual.class,
"NbmWizardPanelVisual.cbAddModule.text")); // NOI18N
@@ -272,14 +270,6 @@ public class NbmWizardPanelVisual extends
javax.swing.JPanel {
}//GEN-LAST:event_cbAddModuleActionPerformed
private void versionComboActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_versionComboActionPerformed
- cbOsgiDeps.setVisible(false); // none of the apache releases support
osgi
-// String version = (String) versionCombo.getSelectedItem();
-// if (RELEASE90_VERSION.equals(version)) {
-// cbOsgiDeps.setEnabled(true);
-// } else {
-// cbOsgiDeps.setEnabled(false);
-// cbOsgiDeps.setSelected(false);
-// }
vgEnabled.performValidation();
}//GEN-LAST:event_versionComboActionPerformed
@@ -299,8 +289,7 @@ public class NbmWizardPanelVisual extends
javax.swing.JPanel {
handle.finish();
handle = null;
}
- }
-
+ }
d.putProperty(NbmWizardIterator.OSGIDEPENDENCIES,
cbOsgiDeps.isSelected());
if (isApp) {
if (cbAddModule.isSelected()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists