[hg] main-silver: #224157: When adding hint to module of NetBean...

  • From: Martin Kozeny < >
  • To: ,
  • Subject: [hg] main-silver: #224157: When adding hint to module of NetBean...
  • Date: Thu, 16 May 2013 04:50:50 -0700

changeset 5a4a4886e656 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/5a4a4886e656
description:
        #224157: When adding hint to module of NetBeans Platform Application, 
platform does not include necessary modules and clusters, for that action. I 
developed routine, which adds those modules and clusters to target platform, 
so application can be build without any errors. I left in test hint java 
class 'add test dependency on Java Hints Test API (and JUnit 4)' TODO text, 
because I am unable to add it by this routine. For suite or standalone 
modules I've omitted this TODO text in test hint java class, because as you 
mentioned before, there is unnecessary.

diffstat:

 
apisupport.ant/src/org/netbeans/modules/apisupport/project/ApisupportAntUtils.java
                                   |  164 +++++++++-
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java
                                 |   25 +-
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/NbProjectProviderImpl.java
                                |   84 +++++
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/queries/ModuleProjectClassPathExtender.java
               |    2 +-
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/suite/SuiteType.java
                                      |   52 +++
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModulesNodeFactory.java
                                |    2 +-
 
apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ApisupportAntUtilsTest.java
                     |   12 +-
 
apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/CompilationDependencyTest.java
                  |    6 +-
 
apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImplTest.java
            |    2 +-
 
apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SingleModulePropertiesTest.java
   |    2 +-
 
apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibrariesTest.java
 |    4 +-
 
apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteUtilsTest.java
               |    2 +-
 apisupport.project/apichanges.xml                                            
                                        |   13 +
 apisupport.project/manifest.mf                                               
                                        |    2 +-
 
apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbModuleProvider.java
                             |   22 +
 
apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbProjectProvider.java
                            |   52 +++
 apisupport.wizards/manifest.mf                                               
                                        |    2 +-
 apisupport.wizards/nbproject/project.xml                                     
                                        |    2 +-
 
apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/CreatedModifiedFiles.java
            |  150 ++++++++-
 
apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/layer.xml
                            |    1 +
 
apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/NewJavaHintIterator.java
           |   90 +++++-
 
apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/javaHintTest.javx
                  |    1 -
 
apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/javaHintTestApp.javx
               |   59 +++
 
maven.apisupport/src/org/netbeans/modules/maven/apisupport/MavenNbModuleImpl.java
                                    |    4 +
 24 files changed, 710 insertions(+), 45 deletions(-)

diffs (1136 lines):

diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ApisupportAntUtils.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ApisupportAntUtils.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ApisupportAntUtils.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ApisupportAntUtils.java
@@ -52,6 +52,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -81,6 +82,10 @@
 import 
org.netbeans.modules.apisupport.project.ProjectXMLManager.CyclicDependencyException;
 import org.netbeans.modules.apisupport.project.api.ManifestManager;
 import org.netbeans.modules.apisupport.project.api.Util;
+import org.netbeans.modules.apisupport.project.suite.SuiteProject;
+import org.netbeans.modules.apisupport.project.ui.customizer.ClusterInfo;
+import org.netbeans.modules.apisupport.project.ui.customizer.SuiteProperties;
+import org.netbeans.modules.apisupport.project.ui.customizer.SuiteUtils;
 import org.netbeans.modules.apisupport.project.universe.LocalizedBundleInfo;
 import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
 import org.netbeans.modules.apisupport.project.universe.ModuleList;
@@ -95,6 +100,7 @@
 import org.openide.filesystems.URLMapper;
 import org.openide.modules.SpecificationVersion;
 import org.openide.util.ChangeSupport;
+import org.openide.util.Exceptions;
 import org.openide.util.NbBundle;
 import org.openide.util.NbCollections;
 import org.openide.util.Utilities;
@@ -370,7 +376,20 @@
      */
     public static boolean addDependency(final NbModuleProject target,
             final String codeNameBase, final @NullAllowed String 
releaseVersion,
-            final @NullAllowed SpecificationVersion version, final boolean 
useInCompiler) throws IOException {
+            final @NullAllowed SpecificationVersion version, final boolean 
useInCompiler, String clusterName) throws IOException {
+        if(target.getModuleType() == NbModuleType.SUITE_COMPONENT && 
clusterName != null) {
+            final Project suiteProject = getSuiteProject(target);
+            if(suiteProject!=null) {
+                final SuiteProperties suiteProps = 
getSuiteProperties((SuiteProject)suiteProject);
+                boolean isClusterIncludedInTargetPlatform;
+                if((isClusterIncludedInTargetPlatform = 
isClusterIncludedInTargetPlatform(suiteProps, clusterName))
+                        && !isModuleIncludedInTargetPlatform(suiteProps, 
codeNameBase)) {
+                        addModuleToTargetPlatform(suiteProject, suiteProps, 
codeNameBase);
+                } else if(!isClusterIncludedInTargetPlatform) {
+                    addClusterToTargetPlatform(suiteProject, suiteProps, 
clusterName, codeNameBase);
+                }
+            }
+        }
         ModuleEntry me = target.getModuleList().getEntry(codeNameBase);
         if (me == null) { // ignore semi-silently (#72611)
             Util.err.log(ErrorManager.INFORMATIONAL, "Trying to add " + 
codeNameBase + // NOI18N
@@ -408,7 +427,20 @@
         return true;
     }
     
-    static void addTestDependency(NbModuleProject prj, String codeNameBase) 
throws IOException {
+    static void addTestDependency(NbModuleProject prj, String codeNameBase, 
String clusterName) throws IOException {
+        if(prj.getModuleType() == NbModuleType.SUITE_COMPONENT && 
clusterName != null) {
+            final Project suiteProject = getSuiteProject(prj);
+            if(suiteProject!=null) {
+                final SuiteProperties suiteProps = 
getSuiteProperties((SuiteProject)suiteProject);
+                boolean isClusterIncludedInTargetPlatform;
+                if((isClusterIncludedInTargetPlatform = 
isClusterIncludedInTargetPlatform(suiteProps, clusterName))
+                        && !isModuleIncludedInTargetPlatform(suiteProps, 
codeNameBase)) {
+                    addModuleToTargetPlatform(suiteProject, suiteProps, 
codeNameBase);
+                } else if(!isClusterIncludedInTargetPlatform) {
+                    addClusterToTargetPlatform(suiteProject, suiteProps, 
clusterName, codeNameBase);
+                }
+            }
+        }
         ModuleEntry me = prj.getModuleList().getEntry(codeNameBase);
         if (me == null) { // ignore semi-silently (#72611)
             Util.err.log(ErrorManager.INFORMATIONAL, "Trying to add " + 
codeNameBase + // NOI18N
@@ -735,4 +767,132 @@
         return ret;
     }
 
+    static SuiteProperties getSuiteProperties(NbModuleProject target) {
+        final Project suiteProject = getSuiteProject(target);
+        if(suiteProject!=null) {
+            return getSuiteProperties((SuiteProject) suiteProject);
 }
+        return null; 
+    }
+    
+    static SuiteProperties getSuiteProperties(SuiteProject suiteProject) {
+        if(suiteProject!=null) {
+            Set<NbModuleProject> subModules = 
SuiteUtils.getSubProjects(suiteProject);
+            return new SuiteProperties(suiteProject, 
suiteProject.getHelper(),
+                suiteProject.getEvaluator(), subModules);
+        }
+        return null; 
+    }
+    
+    static Project getSuiteProject(NbModuleProject target) {
+        File suiteDirectory = 
target.getLookup().lookup(SuiteProvider.class).getSuiteDirectory();
+        if(suiteDirectory!=null) {
+            FileObject suiteDirectoryFO = 
FileUtil.toFileObject(suiteDirectory);
+            if(suiteDirectoryFO != null) {
+                try {
+                    return 
ProjectManager.getDefault().findProject(suiteDirectoryFO);
+                } catch (IOException ex) {
+                    Exceptions.printStackTrace(ex);
+                } catch (IllegalArgumentException ex) {
+                    Exceptions.printStackTrace(ex);
+                }
+            }
+        }
+        return null; 
+    }
+    
+    static boolean isModuleIncludedInTargetPlatform(SuiteProperties 
suiteProps, String codeNameBase) {
+        if(suiteProps != null) {
+            for(String disabledModuleIter : suiteProps.getDisabledModules()) 
{
+                if(disabledModuleIter.equals(codeNameBase)) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+    
+    static boolean isClusterIncludedInTargetPlatform(SuiteProperties 
suiteProps, String clusterName) {
+        if(suiteProps != null) {
+            Set<ClusterInfo> clusterInfoSet = suiteProps.getClusterPath();
+            if(clusterInfoSet!=null) {
+                for(ClusterInfo infoIter : clusterInfoSet) {
+                    
if(infoIter.getClusterDir().getName().equals(clusterName)) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+    
+    static void addModuleToTargetPlatform(final Project suiteProject, final 
SuiteProperties suiteProps, String codeNameBase) {
+        if(suiteProps != null) {
+            Set<String> disabledModules = new 
HashSet<String>(Arrays.asList(suiteProps.getDisabledModules()));
+            for(String disableModuleIter:disabledModules) {
+                if(codeNameBase.equals(disableModuleIter)) {
+                    disabledModules.remove(codeNameBase);
+                    break;
+                }
+            }
+            String [] updatedDiasabledModules = new 
String[disabledModules.size()];
+            disabledModules.toArray(updatedDiasabledModules);
+            suiteProps.setDisabledModules(updatedDiasabledModules);
+            ProjectManager.mutex().writeAccess(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        suiteProps.storeProperties();
+                        
ProjectManager.getDefault().saveProject(suiteProject);
+                    } catch (IOException ex) {
+                        Exceptions.printStackTrace(ex);
+                    }
+                }
+            });
+        }
+    }
+    
+    static void addClusterToTargetPlatform(final Project suiteProject, final 
SuiteProperties suiteProps, String clusterName, String codeNameBase) {
+        if(suiteProps != null) {
+            List<ClusterInfo> clusterInfoSet = new 
ArrayList<ClusterInfo>(suiteProps.getClusterPath());
+            if(suiteProps.getActivePlatform() != null) {
+                File clusterDirectory = null;
+                Set<ModuleEntry> moduleList = 
suiteProps.getActivePlatform().getModules();
+                for(ModuleEntry entryIter:moduleList) {
+                    
if(entryIter.getClusterDirectory().getName().equals(clusterName)) {
+                        clusterDirectory = entryIter.getClusterDirectory();
+                        break;
+                    }
+                }
+                if(clusterDirectory != null) {
+                    ClusterInfo newClusterInfo = 
ClusterInfo.create(clusterDirectory, 
+                        true, true);
+                    clusterInfoSet.add(newClusterInfo);
+                    Set<String> disabledModules = new 
HashSet<String>(Arrays.asList(suiteProps.getDisabledModules()));
+                    for(ModuleEntry entryIter:moduleList) {
+                        
if(entryIter.getClusterDirectory().equals(clusterDirectory)) {
+                            disabledModules.add(entryIter.getCodeNameBase());
+                        }
+                    }
+                    suiteProps.setClusterPath(clusterInfoSet);
+                    disabledModules.remove(codeNameBase);
+                    String [] updatedDiasabledModules = new 
String[disabledModules.size()];
+                    disabledModules.toArray(updatedDiasabledModules);
+                    suiteProps.setDisabledModules(updatedDiasabledModules);
+                    ProjectManager.mutex().writeAccess(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                suiteProps.storeProperties();
+                                
ProjectManager.getDefault().saveProject(suiteProject);
+                            } catch (IOException ex) {
+                                Exceptions.printStackTrace(ex);
+                            }
+                        }
+                    });
+                }
+            }
+        }
+    }
+
+}
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java
@@ -55,13 +55,18 @@
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.netbeans.api.project.Project;
 import org.netbeans.api.project.ProjectManager;
+import static 
org.netbeans.modules.apisupport.project.NbModuleType.NETBEANS_ORG;
+import static 
org.netbeans.modules.apisupport.project.NbModuleType.STANDALONE;
+import static 
org.netbeans.modules.apisupport.project.NbModuleType.SUITE_COMPONENT;
 import org.netbeans.modules.apisupport.project.api.LayerHandle;
 import org.netbeans.modules.apisupport.project.api.ManifestManager;
 import org.netbeans.modules.apisupport.project.spi.LayerUtil;
 import org.netbeans.modules.apisupport.project.spi.NbModuleProvider;
 import org.netbeans.modules.apisupport.project.spi.PlatformJarProvider;
 import org.netbeans.modules.apisupport.project.suite.SuiteProject;
+import org.netbeans.modules.apisupport.project.ui.customizer.SuiteProperties;
 import org.netbeans.modules.apisupport.project.ui.customizer.SuiteUtils;
 import org.netbeans.modules.apisupport.project.universe.ClusterUtils;
 import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
@@ -114,9 +119,25 @@
     @Override public void 
addDependencies(NbModuleProvider.ModuleDependency[] dependencies) throws 
IOException {
         for (NbModuleProvider.ModuleDependency dep : dependencies) {
             if (dep.isTestDependency()) {
-                ApisupportAntUtils.addTestDependency(prj, 
dep.getCodeNameBase());
+                ApisupportAntUtils.addTestDependency(prj, 
dep.getCodeNameBase(), dep.getClusterName());
             } else {
-                ApisupportAntUtils.addDependency(prj, dep.getCodeNameBase(), 
dep.getReleaseVersion(), dep.getVersion(), dep.isUseInCompiler());
+                ApisupportAntUtils.addDependency(prj, dep.getCodeNameBase(), 
dep.getReleaseVersion(), dep.getVersion(), dep.isUseInCompiler(), 
dep.getClusterName());
+            }
+        }
+    }
+
+    @Override public void 
addModulesToTargetPlatform(NbModuleProvider.ModuleDependency[] dependencies) 
throws IOException {
+        final Project suiteProject = ApisupportAntUtils.getSuiteProject(prj);
+        if(suiteProject!=null) {
+            final SuiteProperties suiteProps = 
ApisupportAntUtils.getSuiteProperties((SuiteProject)suiteProject);
+            for (NbModuleProvider.ModuleDependency dep : dependencies) {
+                boolean isClusterIncludedInTargetPlatform;
+                if((isClusterIncludedInTargetPlatform = 
ApisupportAntUtils.isClusterIncludedInTargetPlatform(suiteProps, 
dep.getClusterName()))
+                    && 
!ApisupportAntUtils.isModuleIncludedInTargetPlatform(suiteProps, 
dep.getCodeNameBase())) {
+                    
ApisupportAntUtils.addModuleToTargetPlatform(suiteProject, suiteProps, 
dep.getCodeNameBase());
+                } else if(!isClusterIncludedInTargetPlatform) {
+                    
ApisupportAntUtils.addClusterToTargetPlatform(suiteProject, suiteProps, 
dep.getClusterName(), dep.getCodeNameBase());
+                }
             }
         }
     }
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbProjectProviderImpl.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbProjectProviderImpl.java
new file mode 100644
--- /dev/null
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbProjectProviderImpl.java
@@ -0,0 +1,84 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.apisupport.project;
+
+import java.io.File;
+import java.io.IOException;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.modules.apisupport.project.spi.NbProjectProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+
+/**
+ *
+ * @author mkozeny
+ */
+public class NbProjectProviderImpl implements NbProjectProvider{
+    
+    private final Project prj;
+
+    NbProjectProviderImpl(Project prj) {
+        this.prj = prj;
+    }
+
+    @Override
+    public boolean isNbPlatformApplication() {
+        File suiteDirectory = 
prj.getLookup().lookup(SuiteProvider.class).getSuiteDirectory();
+        if(suiteDirectory!=null) {
+            FileObject suiteDirectoryFO = 
FileUtil.toFileObject(suiteDirectory);
+            if(suiteDirectoryFO != null) {
+                try {
+                    final Project suiteProject = 
ProjectManager.getDefault().findProject(suiteDirectoryFO);
+                } catch (IOException ex) {
+                    Exceptions.printStackTrace(ex);
+                } catch (IllegalArgumentException ex) {
+                    Exceptions.printStackTrace(ex);
+                }
+            }
+        }
+        return false;
+    }
+    
+}
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/queries/ModuleProjectClassPathExtender.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/queries/ModuleProjectClassPathExtender.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/queries/ModuleProjectClassPathExtender.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/queries/ModuleProjectClassPathExtender.java
@@ -121,7 +121,7 @@
                         ModuleEntry entry = 
project.getModuleList().getEntry(cnb);
                         if (entry != null) {
                             if (sourceGroup.getRootFolder() == 
project.getSourceDirectory()) {
-                                cpChanged |= 
ApisupportAntUtils.addDependency(project, cnb, null, null, true);
+                                cpChanged |= 
ApisupportAntUtils.addDependency(project, cnb, null, null, true, null);
                             } else if (sourceGroup.getRootFolder() == 
project.getTestSourceDirectory("unit")) { // NOI18N
                                 ProjectXMLManager pxm = new 
ProjectXMLManager(project);
                                 cpChanged |= pxm.addTestDependency("unit", 
new TestModuleDependency(entry, false, false, true)); // NOI18N
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/suite/SuiteType.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/suite/SuiteType.java
new file mode 100644
--- /dev/null
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/suite/SuiteType.java
@@ -0,0 +1,52 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.apisupport.project.suite;
+
+/**
+ *
+ * @author mkozeny
+ */
+public enum SuiteType {
+    SUITE,
+    APPLICATION
+}
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModulesNodeFactory.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModulesNodeFactory.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModulesNodeFactory.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModulesNodeFactory.java
@@ -252,7 +252,7 @@
             NbModuleProject project = 
ApisupportAntUIUtils.runLibraryWrapperWizard(suiteProvider);
             if (project != null && target != null) {
                 try {
-                    ApisupportAntUtils.addDependency(target, 
project.getCodeNameBase(), null, null, true);
+                    ApisupportAntUtils.addDependency(target, 
project.getCodeNameBase(), null, null, true, null);
                     ProjectManager.getDefault().saveProject(target);
                 } catch (IOException e) {
                     LOG.log(Level.INFO, "could not add dependency on " + 
project.getCodeNameBase() + " to " + target, e);
diff --git 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ApisupportAntUtilsTest.java
 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ApisupportAntUtilsTest.java
--- 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ApisupportAntUtilsTest.java
+++ 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ApisupportAntUtilsTest.java
@@ -228,21 +228,21 @@
     public void testAddDependency() throws Exception {
         NbModuleProject p = generateStandaloneModule("module");
         assertEquals("no dependencies", 0, new 
ProjectXMLManager(p).getDirectDependencies().size());
-        assertTrue("successfully added", ApisupportAntUtils.addDependency(p, 
"org.openide.util", null, new SpecificationVersion("6.1"), true));
+        assertTrue("successfully added", ApisupportAntUtils.addDependency(p, 
"org.openide.util", null, new SpecificationVersion("6.1"), true, null));
         ProjectManager.getDefault().saveProject(p);
         assertEquals("one dependency", 1, new 
ProjectXMLManager(p).getDirectDependencies().size());
-        assertFalse("does not exist", ApisupportAntUtils.addDependency(p, 
"org.openide.i_do_not_exist", null, null, true));
+        assertFalse("does not exist", ApisupportAntUtils.addDependency(p, 
"org.openide.i_do_not_exist", null, null, true, null));
         ProjectManager.getDefault().saveProject(p);
         assertEquals("still one dependency", 1, new 
ProjectXMLManager(p).getDirectDependencies().size());
-        assertFalse("already there", ApisupportAntUtils.addDependency(p, 
"org.openide.util", null, new SpecificationVersion("6.1"), true));
-        assertTrue("upgraded", ApisupportAntUtils.addDependency(p, 
"org.openide.util", null, new SpecificationVersion("6.2"), true));
+        assertFalse("already there", ApisupportAntUtils.addDependency(p, 
"org.openide.util", null, new SpecificationVersion("6.1"), true, null));
+        assertTrue("upgraded", ApisupportAntUtils.addDependency(p, 
"org.openide.util", null, new SpecificationVersion("6.2"), true, null));
         ProjectManager.getDefault().saveProject(p);
         SortedSet<ModuleDependency> deps = new 
ProjectXMLManager(p).getDirectDependencies();
         assertEquals("still one dependency", 1, deps.size());
         assertEquals("6.2", 
deps.iterator().next().getSpecificationVersion());
-        assertFalse("not downgraded", ApisupportAntUtils.addDependency(p, 
"org.openide.util", null, new SpecificationVersion("6.0"), true));
+        assertFalse("not downgraded", ApisupportAntUtils.addDependency(p, 
"org.openide.util", null, new SpecificationVersion("6.0"), true, null));
         new ProjectXMLManager(p).addDependency(new 
ModuleDependency(p.getModuleList().getEntry("org.openide.awt"), null, null, 
true, true));
-        assertFalse("not switched to spec dep", 
ApisupportAntUtils.addDependency(p, "org.openide.awt", null, new 
SpecificationVersion("6.0"), true));
+        assertFalse("not switched to spec dep", 
ApisupportAntUtils.addDependency(p, "org.openide.awt", null, new 
SpecificationVersion("6.0"), true, null));
         ProjectManager.getDefault().saveProject(p);
         deps = new ProjectXMLManager(p).getDirectDependencies();
         assertEquals("still two deps", 2, deps.size());
diff --git 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/CompilationDependencyTest.java
 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/CompilationDependencyTest.java
--- 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/CompilationDependencyTest.java
+++ 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/CompilationDependencyTest.java
@@ -103,7 +103,7 @@
         et.waitFinished();
         assertEquals("Error during ant ...",0,et.result());
         SpecificationVersion invalid = new SpecificationVersion("1000");
-        ApisupportAntUtils.addDependency(testingProject, WINDOWS, null, 
invalid, true);
+        ApisupportAntUtils.addDependency(testingProject, WINDOWS, null, 
invalid, true, null);
         ProjectManager.getDefault().saveProject(testingProject);
         et = ActionUtils.runTarget(buildScript, new String[]{"clean","jar"}, 
null);
         et.waitFinished();
@@ -120,7 +120,7 @@
         FileObject buildScript = findBuildXml(testingProject);
         assertNotNull(buildScript);
         
-        ApisupportAntUtils.addDependency(testingProject, WINDOWS, null, 
null, true);
+        ApisupportAntUtils.addDependency(testingProject, WINDOWS, null, 
null, true, null);
         ProjectManager.getDefault().saveProject(testingProject);
         
         FileObject javaFo = 
testingProject.getSourceDirectory().getFileObject("org/example/testing").createData("JavaFile.java");
@@ -160,7 +160,7 @@
         SuiteProject suite = TestBase.generateSuite(new File(getWorkDir(), 
"projects"), "suite");
         NbModuleProject proj = TestBase.generateSuiteComponent(suite, 
"mod1");
         suite.open();
-        ApisupportAntUtils.addDependency(proj, WINDOWS, null, null, true);
+        ApisupportAntUtils.addDependency(proj, WINDOWS, null, null, true, 
null);
         
         // remove WINDOWS from platform
         EditableProperties ep = 
suite.getHelper().getProperties("nbproject/platform.properties");
diff --git 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImplTest.java
 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImplTest.java
--- 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImplTest.java
+++ 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImplTest.java
@@ -131,7 +131,7 @@
                 null,
                 new File[] { FileUtil.toFile(yyJar)} );
         
-        ApisupportAntUtils.addDependency(project, "yy", null, null, true);
+        ApisupportAntUtils.addDependency(project, "yy", null, null, true, 
null);
         ProjectManager.getDefault().saveProject(project);
         
         URL wrappedJar = FileUtil.urlForArchiveOrDir(new File(wrapperDirF, 
"release/modules/ext/yy.jar"));
diff --git 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SingleModulePropertiesTest.java
 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SingleModulePropertiesTest.java
--- 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SingleModulePropertiesTest.java
+++ 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SingleModulePropertiesTest.java
@@ -190,7 +190,7 @@
         }
         
         // modify project.xml
-        ApisupportAntUtils.addDependency(p, 
"org.netbeans.modules.java.project", "1", null, false);
+        ApisupportAntUtils.addDependency(p, 
"org.netbeans.modules.java.project", "1", null, false, null);
         ProjectManager.getDefault().saveProject(p);
         
         simulatePropertiesOpening(props, p);
diff --git 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibrariesTest.java
 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibrariesTest.java
--- 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibrariesTest.java
+++ 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibrariesTest.java
@@ -149,8 +149,8 @@
         lbinfo.store();
         // MODULE org.example.module3
         module = TestBase.generateSuiteComponent(suite, "module3");
-        ApisupportAntUtils.addDependency(module, "org.example.module2", 
null, null, true);
-        ApisupportAntUtils.addDependency(module, "bar", null, null, true);
+        ApisupportAntUtils.addDependency(module, "org.example.module2", 
null, null, true, null);
+        ApisupportAntUtils.addDependency(module, "bar", null, null, true, 
null);
         lbinfo = 
module.getLookup().lookup(LocalizedBundleInfo.Provider.class).getLocalizedBundleInfo();
         lbinfo.setDisplayName("Module Three");
         lbinfo.store();
diff --git 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteUtilsTest.java
 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteUtilsTest.java
--- 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteUtilsTest.java
+++ 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteUtilsTest.java
@@ -121,7 +121,7 @@
         SubprojectProvider spp = 
SuitePropertiesTest.getSubProjectProvider(suite1);
         assertEquals("two suite components", 2, spp.getSubprojects().size());
 
-        ApisupportAntUtils.addDependency(module2, module1.getCodeNameBase(), 
null, null, true);
+        ApisupportAntUtils.addDependency(module2, module1.getCodeNameBase(), 
null, null, true, null);
         ProjectManager.getDefault().saveProject(module2);
         ProjectXMLManager pxm2 = new ProjectXMLManager(module2);
         assertEquals("one dependency", 1, 
pxm2.getDirectDependencies().size());
diff --git a/apisupport.project/apichanges.xml 
b/apisupport.project/apichanges.xml
--- a/apisupport.project/apichanges.xml
+++ b/apisupport.project/apichanges.xml
@@ -110,6 +110,19 @@
     <changes>
         <change>
             <api name="apisupport_spi"/>
+            <summary>Modified NB module provider for aadding modules to 
target platform</summary>
+            <version major="1" minor="64"/>
+            <date day="14" month="5" year="2013"/>
+            <author login="mkozeny"/>
+            <compatibility addition="yes"/>
+            <description>
+                <code>NbModuleProvider</code> interface now contains method 
<code>addModulesToTargetPlatform</code>
+                for adding modules to target platform also with its clusters 
if necessary.
+            </description>
+            <class package="org.netbeans.modules.apisupport.project.spi" 
name="NbModuleProvider"/>
+        </change>
+        <change>
+            <api name="apisupport_spi"/>
             <summary>Modified branding for internationalization</summary>
             <version major="1" minor="63"/>
             <date day="1" month="5" year="2013"/>
diff --git a/apisupport.project/manifest.mf b/apisupport.project/manifest.mf
--- a/apisupport.project/manifest.mf
+++ b/apisupport.project/manifest.mf
@@ -4,5 +4,5 @@
 OpenIDE-Module-Requires: javax.script.ScriptEngine.freemarker
 OpenIDE-Module-Layer: 
org/netbeans/modules/apisupport/project/ui/resources/layer.xml
 AutoUpdate-Show-In-Client: false
-OpenIDE-Module-Specification-Version: 1.63
+OpenIDE-Module-Specification-Version: 1.64
 
diff --git 
a/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbModuleProvider.java
 
b/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbModuleProvider.java
--- 
a/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbModuleProvider.java
+++ 
b/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbModuleProvider.java
@@ -133,6 +133,14 @@
     void addDependencies(@NonNull ModuleDependency[] dependencies) throws 
IOException;
     
     /**
+     * add/updates the given modules to the project's target platform
+     * @param dependencies list of 
+     * @since 1.64
+     * @throws IOException
+     */
+    void addModulesToTargetPlatform(@NonNull ModuleDependency[] 
dependencies) throws IOException;
+    
+    /**
      * Checks the version of the given dependency.
      * The return value should be what the module currently compiles against
      * (which might be different in some harnesses than the minimum runtime 
dependency).
@@ -180,6 +188,7 @@
         private final SpecificationVersion version;
         private final boolean useInCompiler;
         private boolean testDependency;
+        private final String clusterName;
 
         public ModuleDependency(String codeNameBase, String releaseVersion, 
SpecificationVersion version, boolean useInCompiler) {
             this.testDependency = false;
@@ -187,6 +196,16 @@
             this.releaseVersion = releaseVersion;
             this.version = version;
             this.useInCompiler = useInCompiler;
+            this.clusterName = null;
+        }
+
+        public ModuleDependency(String codeNameBase, String releaseVersion, 
SpecificationVersion version, boolean useInCompiler, String clusterName) {
+            this.testDependency = false;
+            this.codeNameBase = codeNameBase;
+            this.releaseVersion = releaseVersion;
+            this.version = version;
+            this.useInCompiler = useInCompiler;
+            this.clusterName = clusterName;
         }
 
         public String getCodeNameBase() {
@@ -213,6 +232,9 @@
             this.testDependency = isTestDependency;
         }
 
+        public String getClusterName() {
+            return clusterName;
+        }
  
         
     }
diff --git 
a/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbProjectProvider.java
 
b/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbProjectProvider.java
new file mode 100644
--- /dev/null
+++ 
b/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/NbProjectProvider.java
@@ -0,0 +1,52 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.apisupport.project.spi;
+
+/**
+ *
+ * @author mkozeny
+ */
+public interface NbProjectProvider {
+    
+    boolean isNbPlatformApplication();
+}
diff --git a/apisupport.wizards/manifest.mf b/apisupport.wizards/manifest.mf
--- a/apisupport.wizards/manifest.mf
+++ b/apisupport.wizards/manifest.mf
@@ -3,5 +3,5 @@
 OpenIDE-Module: org.netbeans.modules.apisupport.wizards
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/apisupport/project/ui/wizard/common/Bundle.properties
 OpenIDE-Module-Layer: 
org/netbeans/modules/apisupport/project/ui/wizard/common/layer.xml
-OpenIDE-Module-Specification-Version: 1.10
+OpenIDE-Module-Specification-Version: 1.11
 
diff --git a/apisupport.wizards/nbproject/project.xml 
b/apisupport.wizards/nbproject/project.xml
--- a/apisupport.wizards/nbproject/project.xml
+++ b/apisupport.wizards/nbproject/project.xml
@@ -46,7 +46,7 @@
                     <compile-dependency/>
                     <run-dependency>
                         <release-version>1</release-version>
-                        <specification-version>1.59</specification-version>
+                        <specification-version>1.64</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
diff --git 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/CreatedModifiedFiles.java
 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/CreatedModifiedFiles.java
--- 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/CreatedModifiedFiles.java
+++ 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/CreatedModifiedFiles.java
@@ -107,7 +107,6 @@
 import org.openide.loaders.DataObject;
 import org.openide.loaders.DataObjectNotFoundException;
 import org.openide.modules.SpecificationVersion;
-import org.openide.util.Exceptions;
 import org.openide.util.Lookup;
 import org.openide.util.Parameters;
 import org.openide.util.lookup.ServiceProvider;
@@ -347,6 +346,20 @@
                     }
                 }
             }
+            //aggregate all Add Module To Target Platform operations into a 
single operation..
+            AddModuleToTargetPlatform targetPlatfOp = null;
+            Iterator<Operation> it2 = operations.iterator();
+            while (it2.hasNext()) {
+                Operation oper = it2.next();
+                if (oper instanceof AddModuleToTargetPlatform) {
+                    if (targetPlatfOp == null) {
+                        targetPlatfOp = (AddModuleToTargetPlatform) oper;
+                    } else {
+                        
targetPlatfOp.addDependencies(((AddModuleToTargetPlatform) 
oper).getDependencies());
+                        it2.remove();
+                    }
+                }
+            }
             //and now execute
             for (Operation op : operations) {
                 op.run();
@@ -707,6 +720,36 @@
     }
 
     /**
+     * Add a dependency to a list of module dependencies of this project. 
This
+     * means editing of project's <em>nbproject/project.xml</em>. All 
parameters
+     * refers to a module this module will depend on. If a project already 
has a
+     * given dependency it will not be added.
+     *
+     * @param codeNameBase codename base
+     * @param releaseVersion release version, if <code>null</code> will be 
taken
+     * from the entry found in platform
+     * @param version specification version (see {@link 
SpecificationVersion}),
+     * if null will be taken from the entry found in platform
+     * @param useInCompiler do this module needs a module beeing added at a
+     * compile time?
+     * @param clusterName module's cluster name
+     */
+    public Operation addModuleDependency(String codeNameBase, String 
releaseVersion, SpecificationVersion version, boolean useInCompiler, String 
clusterName) {
+        return new AddModuleDependency(project, codeNameBase, 
releaseVersion, version, useInCompiler, false, clusterName);
+    }
+
+    /**
+     * Delegates to {@link #addModuleDependency(String, String,
+     * SpecificationVersion, boolean, String)} passing a given code name 
base and cluster name,
+     * <code>null</code> as release version,
+     * <code>null</code> as version and
+     * <code>true</code> as useInCompiler arguments.
+     */
+    public Operation addModuleDependency(String codeNameBase, String 
clusterName) {
+        return addModuleDependency(codeNameBase, null, null, true, 
clusterName);
+    }
+
+    /**
      * Adds a test dependency to list of test dependencies.
      *
      * @param codeNameBase
@@ -716,17 +759,58 @@
         return new AddModuleDependency(project, codeNameBase, null, null, 
true, true);
     }
 
-    private static final class AddModuleDependency extends AbstractOperation 
{
+    /**
+     * Adds a test dependency to list of test dependencies.
+     *
+     * @param codeNameBase
+     * @param clusterName
+     * @return
+     */
+    public Operation addTestModuleDependency(String codeNameBase, String 
clusterName) {
+        return new AddModuleDependency(project, codeNameBase, null, null, 
true, true, clusterName);
+    }
 
-        private List<NbModuleProvider.ModuleDependency> dependencies;
+    /**
+     * Add a module to a list of module in target platform of this project. 
This
+     * means editing of project's <em>nbproject/project.xml</em>. All 
parameters
+     * refers to a module this module will depend on. If a project already 
has a
+     * given dependency it will not be added.
+     *
+     * @param codeNameBase codename base
+     * @param releaseVersion release version, if <code>null</code> will be 
taken
+     * from the entry found in platform
+     * @param version specification version (see {@link 
SpecificationVersion}),
+     * if null will be taken from the entry found in platform
+     * @param useInCompiler do this module needs a module beeing added at a
+     * compile time?
+     * @param clusterName module's cluster name
+     */
+    public Operation addModuleToTargetPlatform(String codeNameBase, String 
releaseVersion, SpecificationVersion version, boolean useInCompiler, String 
clusterName) {
+        return new AddModuleToTargetPlatform(project, codeNameBase, 
releaseVersion, version, useInCompiler, false, clusterName);
+    }
+
+    /**
+     * Delegates to {@link #addModuleToTargetPlatform(String, String,
+     * SpecificationVersion, boolean, String)} passing a given code name 
base,
+     * <code>null</code> as release version,
+     * <code>null</code> as version and
+     * <code>true</code> as useInCompiler arguments.
+     */
+    public Operation addModuleToTargetPlatform(String codeNameBase, String 
clusterName) {
+        return addModuleToTargetPlatform(codeNameBase, null, null, true, 
clusterName);
+    }
+    
+    private static abstract class AddOperation extends AbstractOperation {
+
+        protected List<NbModuleProvider.ModuleDependency> dependencies;
         private Map<String, ModuleDependency> codenamebaseMap;
 
-        public AddModuleDependency(Project project, String codeNameBase,
-                String releaseVersion, SpecificationVersion specVersion, 
boolean useInCompiler, boolean test) {
+        public AddOperation(Project project, String codeNameBase,
+                String releaseVersion, SpecificationVersion specVersion, 
boolean useInCompiler, boolean test, String clusterName) {
             super(project);
             this.dependencies = new ArrayList<ModuleDependency>();
             this.codenamebaseMap = new HashMap<String, ModuleDependency>();
-            ModuleDependency module = new ModuleDependency(codeNameBase, 
releaseVersion, specVersion, useInCompiler);
+            ModuleDependency module = new ModuleDependency(codeNameBase, 
releaseVersion, specVersion, useInCompiler, clusterName);
             if (test) {
                 module.setTestDependency(true);
             }
@@ -734,10 +818,38 @@
             getModifiedPathsSet().add(getModuleInfo().getProjectFilePath()); 
// NOI18N
         }
 
+        public AddOperation(Project project, String codeNameBase,
+                String releaseVersion, SpecificationVersion specVersion, 
boolean useInCompiler, boolean test) {
+            this(project, codeNameBase, releaseVersion, specVersion, 
useInCompiler, test, null);
+        }
+
         public List<ModuleDependency> getDependencies() {
             return dependencies;
         }
 
+        protected void addDependencies(List<ModuleDependency> list) {
+            for (ModuleDependency md : list) {
+                ModuleDependency res = 
codenamebaseMap.get(md.getCodeNameBase());
+                if (res != null) {
+                    //TODO update restrictions somehow?
+                } else {
+                    codenamebaseMap.put(md.getCodeNameBase(), md);
+                    dependencies.add(md);
+                }
+            }
+        }
+    }
+
+    private static final class AddModuleDependency extends AddOperation {
+
+        public AddModuleDependency(Project project, String codeNameBase, 
String releaseVersion, SpecificationVersion specVersion, boolean 
useInCompiler, boolean test, String clusterName) {
+            super(project, codeNameBase, releaseVersion, specVersion, 
useInCompiler, test, clusterName);
+        }
+
+        public AddModuleDependency(Project project, String codeNameBase, 
String releaseVersion, SpecificationVersion specVersion, boolean 
useInCompiler, boolean test) {
+            super(project, codeNameBase, releaseVersion, specVersion, 
useInCompiler, test);
+        }
+        
         @Override
         public void run() throws IOException {
             getModuleInfo().addDependencies(dependencies.toArray(new 
NbModuleProvider.ModuleDependency[0]));
@@ -745,17 +857,27 @@
             ProjectManager.getDefault().saveProject(getProject());
         }
 
-        private void addDependencies(List<ModuleDependency> list) {
-            for (ModuleDependency md : list) {
-                ModuleDependency res = 
codenamebaseMap.get(md.getCodeNameBase());
-                if (res != null) {
-                    //TODO update restrictions somehow?
-                } else {
-                    codenamebaseMap.put(md.getCodeNameBase(), md);
-                    dependencies.add(md);
+        
                 }
+
+    private static final class AddModuleToTargetPlatform extends 
AddOperation {
+
+        public AddModuleToTargetPlatform(Project project, String 
codeNameBase, String releaseVersion, SpecificationVersion specVersion, 
boolean useInCompiler, boolean test, String clusterName) {
+            super(project, codeNameBase, releaseVersion, specVersion, 
useInCompiler, test, clusterName);
             }
+        
+        public AddModuleToTargetPlatform(Project project, String 
codeNameBase, String releaseVersion, SpecificationVersion specVersion, 
boolean useInCompiler, boolean test) {
+            super(project, codeNameBase, releaseVersion, specVersion, 
useInCompiler, test);
         }
+
+        
+        @Override
+        public void run() throws IOException {
+            
getModuleInfo().addModulesToTargetPlatform(dependencies.toArray(new 
NbModuleProvider.ModuleDependency[0]));
+            // XXX consider this carefully
+            ProjectManager.getDefault().saveProject(getProject());
+        }
+
     }
 
     /**
diff --git 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/layer.xml
 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/layer.xml
--- 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/layer.xml
+++ 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/layer.xml
@@ -61,6 +61,7 @@
             <file name="quickSearch.java" 
url="../quicksearch/quickSearch.javx"/>
             <file name="contextProvider.java" 
url="../codegenerator/contextProvider.javx"/>
             <file name="javaHint.java" url="../javahint/javaHint.javx"/>
+            <file name="javaHintTestApp.java" 
url="../javahint/javaHintTestApp.javx"/>
             <file name="javaHintTest.java" 
url="../javahint/javaHintTest.javx"/>
             <file name="template_myplugin-helpset.xml" 
url="../javahelp/template_myplugin-helpset.xml"/>
             <file name="template_myplugin.xml" 
url="../javahelp/template_myplugin.hs"/>
diff --git 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/NewJavaHintIterator.java
 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/NewJavaHintIterator.java
--- 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/NewJavaHintIterator.java
+++ 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/NewJavaHintIterator.java
@@ -45,9 +45,11 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
+import org.netbeans.api.project.Project;
 import org.netbeans.api.templates.TemplateRegistration;
 import org.netbeans.modules.apisupport.project.api.UIUtil;
 import org.netbeans.modules.apisupport.project.spi.NbModuleProvider;
+import org.netbeans.modules.apisupport.project.spi.NbProjectProvider;
 import 
org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator;
 import 
org.netbeans.modules.apisupport.project.ui.wizard.common.CreatedModifiedFiles;
 import org.openide.WizardDescriptor;
@@ -84,13 +86,78 @@
         CreatedModifiedFiles cmf = new 
CreatedModifiedFiles(model.getProject());
 
         //add module dependency
-        
cmf.add(cmf.addModuleDependency("org.netbeans.modules.java.source")); // 
NOI18N
-        cmf.add(cmf.addModuleDependency("org.netbeans.spi.java.hints")); // 
NOI18N
-        cmf.add(cmf.addModuleDependency("org.netbeans.spi.editor.hints")); 
// NOI18N
+        cmf.add(cmf.addModuleDependency("org.netbeans.modules.java.source", 
"java")); // NOI18N
+        cmf.add(cmf.addModuleDependency("org.netbeans.spi.java.hints", 
"java")); // NOI18N
+        cmf.add(cmf.addModuleDependency("org.netbeans.spi.editor.hints", 
"ide")); // NOI18N
         cmf.add(cmf.addModuleDependency("org.openide.util")); // NOI18N
-        cmf.add(cmf.addModuleDependency("org.netbeans.libs.javacapi")); // 
NOI18N
-        
cmf.add(cmf.addTestModuleDependency("org.netbeans.modules.java.hints.test"));
-        cmf.add(cmf.addTestModuleDependency("org.netbeans.libs.junit4"));
+        cmf.add(cmf.addModuleDependency("org.netbeans.libs.javacapi", 
"java")); // NOI18N
+        
cmf.add(cmf.addTestModuleDependency("org.netbeans.modules.java.hints.test", 
"java"));
+        cmf.add(cmf.addTestModuleDependency("org.netbeans.libs.junit4", 
"extra"));
+        cmf.add(cmf.addTestModuleDependency("org.netbeans.modules.nbjunit", 
"harness")); // NOI18N
+        
+
+        //add module to target platform
+        
+        //java cluster
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.classfile", 
"java")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.libs.javacimpl", 
"java")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.spi.java.hints", 
"java")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.java.hints.test", 
"java")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.java.lexer", 
"java")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.java.platform", 
"java")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.java.project", 
"java")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.api.java", 
"java")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.lib.nbjavac", 
"java")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.java.preprocessorbridge",
 "java")); // NOI18N
+        
+        //extide cluster
+        cmf.add(cmf.addModuleToTargetPlatform("org.apache.tools.ant.module", 
"extide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.options.java", 
"extide")); // NOI18N
+        
+        //harness cluster
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.insane", 
"harness")); // NOI18N
+        
+        //ide cluster
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.project.ant", 
"ide")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.apache.xml.resolver", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.api.java.classpath", 
"ide")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.diff", 
"ide")); // NOI18N ?
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.actions", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.fold", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.fold.nbui",
 "ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.errorstripe.api",
 "ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.errorstripe",
 "ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.guards", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.indent", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.indent.project",
 "ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.lib", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.lib2", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.options.editor", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.settings", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.settings.storage",
 "ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.editor.util", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.project.libraries",
 "ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.libs.freemarker", 
"ide")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.lexer", 
"ide")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.libs.lucene", 
"ide")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.spi.navigator", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.parsing.api", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.parsing.lucene", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.projectapi", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.project.indexingbridge",
 "ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.projectuiapi", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.refactoring.api", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.code.analysis", 
"ide")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.spi.tasklist", 
"ide")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.xml.catalog", 
"ide")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.api.xml", 
"ide")); // NOI18N
+        
+        //platform cluster
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.autoupdate.services",
 "platform")); // NOI18N
+        
cmf.add(cmf.addModuleToTargetPlatform("org.netbeans.modules.autoupdate.ui", 
"platform")); // NOI18N
+        cmf.add(cmf.addModuleToTargetPlatform("org.openide.execution", 
"platform")); // NOI18N
+        
         
         String className = model.getClassName();
         FileObject hintTemplate = 
CreatedModifiedFiles.getTemplate("javaHint.java"); // NOI18N
@@ -112,7 +179,12 @@
         cmf.add(cmf.createFileWithSubstitutions(hintPath, hintTemplate, 
replaceTokens));
 
         String testPath = model.getDefaultPackagePath(className + 
"Test.java", false, true); // NOI18N
-        FileObject testTemplate = 
CreatedModifiedFiles.getTemplate("javaHintTest.java"); // NOI18N
+        FileObject testTemplate = null;
+        if(getProjectProvider(model.getProject()).isNbPlatformApplication()) 
{
+            testTemplate = 
CreatedModifiedFiles.getTemplate("javaHintTestApp.java"); // NOI18N
+        } else {
+            testTemplate = 
CreatedModifiedFiles.getTemplate("javaHintTest.java"); // NOI18N
+        }
         assert testTemplate != null;
 
         cmf.add(cmf.createFileWithSubstitutions(testPath, testTemplate, 
replaceTokens));
@@ -121,6 +193,10 @@
         model.setCreatedModifiedFiles(cmf);
     }
 
+    private static NbProjectProvider getProjectProvider(Project prj) {
+            return prj.getLookup().lookup(NbProjectProvider.class);
+    }
+
     static final class DataModel extends BasicWizardIterator.BasicDataModel {
 
         private CreatedModifiedFiles files;
diff --git 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/javaHintTest.javx
 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/javaHintTest.javx
--- 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/javaHintTest.javx
+++ 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/javaHintTest.javx
@@ -9,7 +9,6 @@
 import org.netbeans.modules.java.hints.test.api.HintTest;
 
 /* TODO to make this test work:
-   - add test dependency on Java Hints Test API (and JUnit 4)
    - to ensure that the newest Java language features supported by the IDE 
are available,
      regardless of which JDK you build the module with:
    -- for Ant-based modules, add "requires.nb.javac=true" into 
nbproject/project.properties
diff --git 
a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/javaHintTestApp.javx
 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/javaHintTestApp.javx
new file mode 100644
--- /dev/null
+++ 
b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/javahint/javaHintTestApp.javx
@@ -0,0 +1,59 @@
+<#assign licenseFirst = "/*">
+<#assign licensePrefix = " * ">
+<#assign licenseLast = " */">
+<#include "${project.licensePath}">
+
+package ${PACKAGE_NAME};
+
+import org.junit.Test;
+import org.netbeans.modules.java.hints.test.api.HintTest;
+
+/* TODO to make this test work:
+   - add test dependency on Java Hints Test API (and JUnit 4)
+   - to ensure that the newest Java language features supported by the IDE 
are available,
+     regardless of which JDK you build the module with:
+   -- for Ant-based modules, add "requires.nb.javac=true" into 
nbproject/project.properties
+   -- for Maven-based modules, use dependency:copy in validate phase to 
create
+      target/endorsed/org-netbeans-libs-javacapi-*.jar and add to 
endorseddirs
+      in maven-compiler-plugin and maven-surefire-plugin configuration
+      See: http://wiki.netbeans.org/JavaHintsTestMaven
+ */
+public class ${CLASS_NAME}Test {
+
+    @Test
+    public void testWarningProduced() throws Exception {
+        HintTest.create()
+                .input("package test;\n" +
+                       "public class Test {\n" +
+                       "    public static void main(String[] args) {\n" +
+                       "        assert args[0].equals(\"\");\n" +
+                       "    }\n" +
+                       "}\n")
+                .run(${CLASS_NAME}.class)
+                .assertWarnings("3:23-3:29:verifier:" + 
Bundle.ERR_${CLASS_NAME}());
+    }
+
+<#if GENERATE_FIX??>
+    @Test
+    public void testFixWorking() throws Exception {
+        HintTest.create()
+                .input("package test;\n" +
+                       "public class Test {\n" +
+                       "    public static void main(String[] args) {\n" +
+                       "        assert args[0].equals(\"\");\n" +
+                       "    }\n" +
+                       "}\n")
+                .run(${CLASS_NAME}.class)
+                .findWarning("3:23-3:29:verifier:" + 
Bundle.ERR_${CLASS_NAME}())
+                .applyFix()
+                .assertCompilable()
+                //TODO: change to match expected output
+                .assertOutput("package test;\n" +
+                              "public class Test {\n" +
+                              "    public static void main(String[] args) 
{\n" +
+                              "        assert args[0].equals(\"\");\n" +
+                              "    }\n" +
+                              "}\n");
+    }
+</#if>
+}
diff --git 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/MavenNbModuleImpl.java
 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/MavenNbModuleImpl.java
--- 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/MavenNbModuleImpl.java
+++ 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/MavenNbModuleImpl.java
@@ -347,6 +347,10 @@
         dependencyAdder.run();
     }
 
+    @Override public void 
addModulesToTargetPlatform(NbModuleProvider.ModuleDependency[] dependencies) 
throws IOException {
+        
+    }
+
     /**
      * 6.7 and higher apisupport uses this to add projects to Libraries for 
suite.
      *

[hg] main-silver: #224157: When adding hint to module of NetBean...

Martin Kozeny 05/16/2013

<Possible follow-up(s)>

[hg] main-silver: #224157: When adding hint to module of NetBean...

Martin Kozeny 05/16/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