[hg] main-silver: #237827 split system and user properties when ...

  • From: Milos Kleint < >
  • To: ,
  • Subject: [hg] main-silver: #237827 split system and user properties when ...
  • Date: Fri, 01 Nov 2013 18:36:02 +0000

changeset 1ef858a2ecb9 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/1ef858a2ecb9
description:
        #237827 split system and user properties when loading projects

diffstat:

 
maven.embedder/src/org/netbeans/modules/maven/embedder/NBPluginParameterExpressionEvaluator.java
 |  24 +++++++--
 maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java                 
                    |  14 +++--
 maven/src/org/netbeans/modules/maven/api/PluginPropertyUtils.java            
                    |  12 +++-
 maven/src/org/netbeans/modules/maven/modelcache/MavenProjectCache.java       
                    |  18 +++++--
 4 files changed, 48 insertions(+), 20 deletions(-)

diffs (188 lines):

diff --git 
a/maven.embedder/src/org/netbeans/modules/maven/embedder/NBPluginParameterExpressionEvaluator.java
 
b/maven.embedder/src/org/netbeans/modules/maven/embedder/NBPluginParameterExpressionEvaluator.java
--- 
a/maven.embedder/src/org/netbeans/modules/maven/embedder/NBPluginParameterExpressionEvaluator.java
+++ 
b/maven.embedder/src/org/netbeans/modules/maven/embedder/NBPluginParameterExpressionEvaluator.java
@@ -66,17 +66,20 @@
 
     private final String basedir;
 
-    private final Map<? extends String,? extends String> properties;
+    private final Map<? extends String,? extends String> systemProperties;
+    private final Map<? extends String,? extends String> userProperties;
     
-    private Settings settings;
+    private final Settings settings;
 
     public NBPluginParameterExpressionEvaluator( 
                                                MavenProject project, 
                                                Settings settings,
-                                               Map<? extends String,? 
extends String> properties )
+                                               Map<? extends String,? 
extends String> systemProperties,
+                                               Map<? extends String,? 
extends String> userProperties)
     {
         this.pathTranslator = new DefaultPathTranslator();
-        this.properties = properties;
+        this.systemProperties = systemProperties;
+        this.userProperties = userProperties;
         this.project = project;
         this.settings = settings;
 
@@ -327,21 +330,30 @@
         {
             // The CLI should win for defining properties
 
-            if ( ( value == null ) && ( properties != null ) )
+            if ( ( value == null ) && ( userProperties != null ) )
             {
                 // We will attempt to get nab a system property as a way to 
specify a
                 // parameter to a plugins. My particular case here is 
allowing the surefire
                 // plugin to run a single test so I want to specify that 
class on the cli
                 // as a parameter.
 
-                value = properties.get(expression);
+                value = userProperties.get(expression);
             }
 
             if ( ( value == null ) && ( ( project != null ) && ( 
project.getProperties() != null ) ) )
             {
                 value = project.getProperties().getProperty( expression );
             }
+            //system props come after model props
+            if ( ( value == null ) && ( systemProperties != null ) )
+            {
+                // We will attempt to get nab a system property as a way to 
specify a
+                // parameter to a plugins. My particular case here is 
allowing the surefire
+                // plugin to run a single test so I want to specify that 
class on the cli
+                // as a parameter.
 
+                value = systemProperties.get(expression);
+            }
         }
 
         if ( value instanceof String )
diff --git a/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java 
b/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java
--- a/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java
+++ b/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java
@@ -266,11 +266,11 @@
             req.setPom(projectFile);
             req.setNoSnapshotUpdates(true);
             req.setUpdateSnapshots(false);
-            Properties props = 
MavenProjectCache.createSystemPropsForProjectLoading(null);
+            Properties props = 
MavenProjectCache.createSystemPropsForProjectLoading();
             if (properties != null) {
-                props.putAll(properties);
+                req.setUserProperties(props);
             }
-            req.setUserProperties(props);
+            req.setSystemProperties(props);
             //MEVENIDE-634 i'm wondering if this fixes the issue
             req.setInteractiveMode(false);
             req.setOffline(true);
@@ -318,7 +318,8 @@
         req.setInteractiveMode(false);
         req.setRecursive(false);
         req.setOffline(true);
-        
req.setUserProperties(MavenProjectCache.createSystemPropsForProjectLoading(active.getProperties()));
+        
req.setSystemProperties(MavenProjectCache.createSystemPropsForProjectLoading());
+        
req.setUserProperties(MavenProjectCache.createUserPropsForProjectLoading(active.getProperties()));
 
         ProjectBuildingRequest request = req.getProjectBuildingRequest();
         
request.setRemoteRepositories(project.getRemoteArtifactRepositories());
@@ -355,10 +356,13 @@
         if (platformProvider != null) { // may be null inside 
PackagingProvider
             
props.putAll(platformProvider.getJavaPlatform().getSystemProperties());
         }
-        
props.putAll(configProvider.getActiveConfiguration().getProperties());
         return props;
     }
 
+    public  Map<? extends String,? extends String> 
createUserPropsForPropertyExpressions() {
+         return 
NbCollections.checkedMapByCopy(configProvider.getActiveConfiguration().getProperties(),
 String.class, String.class, true);
+    }
+
     /**
      * getter for the maven's own project representation.. this instance is 
cached but gets reloaded
      * when one the pom files have changed.
diff --git 
a/maven/src/org/netbeans/modules/maven/api/PluginPropertyUtils.java 
b/maven/src/org/netbeans/modules/maven/api/PluginPropertyUtils.java
--- a/maven/src/org/netbeans/modules/maven/api/PluginPropertyUtils.java
+++ b/maven/src/org/netbeans/modules/maven/api/PluginPropertyUtils.java
@@ -537,7 +537,8 @@
             eval =  new NBPluginParameterExpressionEvaluator(
                 mvnprj,
                 ss,
-                prj.createSystemPropsForPropertyExpressions());
+                prj.createSystemPropsForPropertyExpressions(),
+                prj.createUserPropsForPropertyExpressions());
             mvnprj.setContextValue(CONTEXT_EXPRESSION_EVALUATOR, eval);
         }
         return eval;
@@ -554,7 +555,8 @@
         if (eval != null) {
             return eval;
         }
-        Map<? extends String,? extends String> props = 
Collections.emptyMap();
+        Map<? extends String,? extends String> sysprops = 
Collections.emptyMap();
+        Map<? extends String,? extends String> userprops = 
Collections.emptyMap();
         File basedir = prj.getBasedir();
         if (basedir != null) {
         FileObject bsd = FileUtil.toFileObject(basedir);
@@ -563,7 +565,8 @@
             if (p != null) {
                 NbMavenProjectImpl project = 
p.getLookup().lookup(NbMavenProjectImpl.class);
                 if (project != null) {
-                    props = 
project.createSystemPropsForPropertyExpressions();
+                    sysprops = 
project.createSystemPropsForPropertyExpressions();
+                    userprops = 
project.createUserPropsForPropertyExpressions();
                 }
             }
         }
@@ -575,7 +578,8 @@
         eval = new NBPluginParameterExpressionEvaluator(
                 prj,
                 ss,
-                props);
+                sysprops,
+                userprops);
         prj.setContextValue(CONTEXT_EXPRESSION_EVALUATOR, eval);
         return eval;
     }
diff --git 
a/maven/src/org/netbeans/modules/maven/modelcache/MavenProjectCache.java 
b/maven/src/org/netbeans/modules/maven/modelcache/MavenProjectCache.java
--- a/maven/src/org/netbeans/modules/maven/modelcache/MavenProjectCache.java
+++ b/maven/src/org/netbeans/modules/maven/modelcache/MavenProjectCache.java
@@ -165,7 +165,8 @@
             // #135070
             req.setRecursive(false);
             req.setOffline(true);
-            
req.setUserProperties(createSystemPropsForProjectLoading(active.getProperties()));
+            
req.setUserProperties(createUserPropsForProjectLoading(active.getProperties()));
+            req.setSystemProperties(createSystemPropsForProjectLoading());
             res = projectEmbedder.readProjectWithDependencies(req, true);
             newproject = res.getProject();
             
@@ -274,16 +275,23 @@
     }
 
     //#158700
-    public static Properties createSystemPropsForProjectLoading(Map<String, 
String> activeConfiguration) {
+    public static Properties createSystemPropsForProjectLoading() {
         Properties props = cloneStaticProps();
-        if (activeConfiguration != null) {
-            props.putAll(activeConfiguration);
-        }
+       
         //TODO the properties for java.home and maybe others shall be 
relevant to the project setup not ide setup.
         // we got a chicken-egg situation here, the jdk used in project can 
be defined in the pom.xml file.
         return props;
     }  
     
+    public static Properties createUserPropsForProjectLoading(Map<String, 
String> activeConfiguration) {
+        Properties props = new Properties();
+        if (activeConfiguration != null) {
+            props.putAll(activeConfiguration);
+        }
+        return props;
+    }
+    
+    
     private static Mutex getMutex(File pomFile) {
         synchronized (file2Mutex) {
             Mutex mutex = file2Mutex.get(pomFile);

[hg] main-silver: #237827 split system and user properties when ...

Milos Kleint 11/01/2013

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 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