[hg] main-silver: #211638 less file saves

  • From: Milos Kleint < >
  • To: ,
  • Subject: [hg] main-silver: #211638 less file saves
  • Date: Fri, 12 Apr 2013 03:46:58 -0700

changeset 4e6af71cfee8 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/4e6af71cfee8
description:
        #211638 less file saves

diffstat:

 
maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
 |  51 +++++----
 1 files changed, 30 insertions(+), 21 deletions(-)

diffs (99 lines):

diff --git 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
--- 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
+++ 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
@@ -160,10 +160,31 @@
                     addModuleToApplication(appDir, new 
ProjectInfo("${project.groupId}", nbm.artifactId, "${project.version}", 
nbm.packageName), null); // NOI18N
                 }
             }
+            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).
-                addNbmPluginOsgiParameter(projFile);
+                ModelOperation<POMModel> osgi = 
addNbmPluginOsgiParameter(projFile);
+                if (osgi != null) {
+                    opers.add(osgi);
             }
+            }
+            if ("SNAPSHOT".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);
+                        }
+                    }
+                }
+            }           
+            
+            //TODO what is this supposed to do?
             Set<FileObject> projects = 
ArchetypeWizards.openProjects(projFile, new File(projFile, "application"));
             for (FileObject project : projects) {
                 Project prj = 
ProjectManager.getDefault().findProject(project);
@@ -175,9 +196,7 @@
                     continue;
                 }
             }
-            if ("SNAPSHOT".equals(version)) { // NOI18N
-                addSnapshotRepo(projFile);
-            }
+            
             return projects;
     }
     
@@ -258,34 +277,26 @@
     @Override
     public final void removeChangeListener(ChangeListener l) {}
 
-    private static void addNbmPluginOsgiParameter(File projFile) throws 
IOException {
+    private static ModelOperation<POMModel> addNbmPluginOsgiParameter(File 
projFile) throws IOException {
         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) {
-                    return; // invalid? #184466
+                    return null; // invalid? #184466
                 }
                 NbMavenProject mav = 
prj.getLookup().lookup(NbMavenProject.class);
-                ModelOperation<POMModel> op = new 
AddOSGiParamToNbmPluginConfiguration(true, mav.getMavenProject());
-                Utilities.performPOMModelOperations(pom, 
Collections.singletonList(op));
+                return  new AddOSGiParamToNbmPluginConfiguration(true, 
mav.getMavenProject());
             }
         }
         //TODO report inability to create? or if the file doesn't exist, it 
was already
         //reported?
+        return null;
    }
 
-    private static void addSnapshotRepo(File projFile) throws IOException {
-        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) {
-                    return;
-                }
-                Utilities.performPOMModelOperations(pom, 
Collections.singletonList(new ModelOperation<POMModel>() {
+    private static ModelOperation<POMModel> addSnapshotRepo() throws 
IOException {
+        return new ModelOperation<POMModel>() {
                     public @Override void performOperation(POMModel model) {
                         Repository repo = 
model.getFactory().createRepository();
                         repo.setId("netbeans-snapshot"); // NOI18N
@@ -298,9 +309,7 @@
                         
repo.setUrl("http://bits.netbeans.org/netbeans/trunk/maven-snapshot/";); // 
NOI18N
                         model.getProject().addRepository(repo);
                     }
-                }));
-            }
-        }
+                };
    }
 
     private static void trimInheritedFromNbmProject(File projFile) throws 
IOException {

[hg] main-silver: #211638 less file saves

Milos Kleint 04/12/2013

Project Features

About this Project

APIsupport was started in November 2009, is owned by Antonin Nebuzelsky, and has 43 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close