ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1343304 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/Main.java
Date Mon, 28 May 2012 15:54:01 GMT
Author: jkf
Date: Mon May 28 15:54:00 2012
New Revision: 1343304

URL: http://svn.apache.org/viewvc?rev=1343304&view=rev
Log:
Bug 51792 - Unable to override system properties with 1.8.2

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/Main.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1343304&r1=1343303&r2=1343304&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon May 28 15:54:00 2012
@@ -24,6 +24,10 @@ Fixed bugs:
  * Updated documentation to fix spelling errors / broken links.
    Bugzilla Reports 53215, 53291, 53202
    
+ * Unable to override system properties. It was not possible not to override
+   system properties from the command line (or from a property file).
+   Bugzilla Report 51792
+   
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Main.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Main.java?rev=1343304&r1=1343303&r2=1343304&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Main.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Main.java Mon May 28 15:54:00 2012
@@ -36,6 +36,7 @@ import java.util.Vector;
 import org.apache.tools.ant.input.DefaultInputHandler;
 import org.apache.tools.ant.input.InputHandler;
 import org.apache.tools.ant.launch.AntMain;
+import org.apache.tools.ant.property.GetProperty;
 import org.apache.tools.ant.property.ResolvePropertyMap;
 import org.apache.tools.ant.util.ClasspathUtils;
 import org.apache.tools.ant.util.FileUtils;
@@ -147,6 +148,17 @@ public class Main implements AntMain {
      * proxy flag: default is false
      */
     private boolean proxy = false;
+    
+    
+    private static final GetProperty NOPROPERTIES = new GetProperty(){
+        @Override
+        public Object getProperty(String aName) {
+            // No existing property takes precedence
+            return null;
+        }};
+    
+    
+
 
     /**
      * Prints the message of the Throwable if it (the message) is not
@@ -760,30 +772,7 @@ public class Main implements AntMain {
                     }
                 }
 
-
-
-                project.init();
-
-                // resolve properties
-                PropertyHelper propertyHelper
-                    = (PropertyHelper) PropertyHelper.getPropertyHelper(project);
-                HashMap props = new HashMap(definedProps);
-                new ResolvePropertyMap(project, propertyHelper,
-                                       propertyHelper.getExpanders())
-                    .resolveAllProperties(props, null, false);
-
-                // set user-define properties
-                for (Iterator e = props.entrySet().iterator(); e.hasNext(); ) {
-                    Map.Entry ent = (Map.Entry) e.next();
-                    String arg = (String) ent.getKey();
-                    Object value = ent.getValue();
-                    project.setUserProperty(arg, String.valueOf(value));
-                }
-
-                project.setUserProperty(MagicNames.ANT_FILE,
-                                        buildFile.getAbsolutePath());
-                project.setUserProperty(MagicNames.ANT_FILE_TYPE,
-                                        MagicNames.ANT_FILE_TYPE_FILE);
+                setProperties(project);
 
                 project.setKeepGoingMode(keepGoingMode);
                 if (proxy) {
@@ -849,6 +838,33 @@ public class Main implements AntMain {
         }
     }
 
+    private void setProperties(final Project project) {
+        
+        project.init();
+        
+        // resolve properties
+        PropertyHelper propertyHelper = (PropertyHelper) PropertyHelper
+                .getPropertyHelper(project);
+        HashMap props = new HashMap(definedProps);
+        
+        ResolvePropertyMap resolver = new ResolvePropertyMap(project,
+                NOPROPERTIES, propertyHelper.getExpanders());
+        resolver.resolveAllProperties(props, null, false);
+
+        // set user-define properties
+        for (Iterator e = props.entrySet().iterator(); e.hasNext(); ) {
+            Map.Entry ent = (Map.Entry) e.next();
+            String arg = (String) ent.getKey();
+            Object value = ent.getValue();
+            project.setUserProperty(arg, String.valueOf(value));
+        }
+
+        project.setUserProperty(MagicNames.ANT_FILE,
+                                buildFile.getAbsolutePath());
+        project.setUserProperty(MagicNames.ANT_FILE_TYPE,
+                                MagicNames.ANT_FILE_TYPE_FILE);
+    }
+
     /**
      * Adds the listeners specified in the command line arguments,
      * along with the default listener, to the specified project.



Mime
View raw message