You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by gs...@apache.org on 2007/08/03 08:55:03 UTC

svn commit: r562392 - in /incubator/ivy/core/trunk: doc/use/artifactproperty.html src/java/org/apache/ivy/ant/IvyArtifactProperty.java

Author: gscokart
Date: Fri Aug  3 01:55:02 2007
New Revision: 562392

URL: http://svn.apache.org/viewvc?view=rev&rev=562392
Log:
IMPROVEMENT: artifactproperty overwrites the existing properties (IVY-587)

Modified:
    incubator/ivy/core/trunk/doc/use/artifactproperty.html
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java

Modified: incubator/ivy/core/trunk/doc/use/artifactproperty.html
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/doc/use/artifactproperty.html?view=diff&rev=562392&r1=562391&r2=562392
==============================================================================
--- incubator/ivy/core/trunk/doc/use/artifactproperty.html (original)
+++ incubator/ivy/core/trunk/doc/use/artifactproperty.html Fri Aug  3 01:55:02 2007
@@ -33,7 +33,13 @@
 Please prefer the use of retrieve + standard ant path creation, which make your build more independent from ivy (once artifacts are properly retrieved, ivy is not required any more).
 
 The property name and value are generated using the classical pattern concept, all artifact tokens and ivy variables being available.
-  
+
+<span class="since">since 2.0</span> This tag will follow the ant usual behavior for properties.  If a property of the same name already exist, it's value will be unchanged.  This behavior can be changed using the 'overwrite' attribute.
+<i>WARNING : Before 2.0, the behavior was to overwrite the properties.  Since 2.0, the default is to not overwrite to properties</i>
+
+
+<h1>Attributes</h1>
+
 <table class="ant">
 <thead>
     <tr><th class="ant-att">Attribute</th><th class="ant-desc">Description</th><th class="ant-req">Required</th></tr>
@@ -49,6 +55,7 @@
     <tr><td>validate</td><td>true to force ivy files validation against ivy.xsd, false to force no validation</td>
         <td>No. Defaults to default ivy value (as configured in configuration file)</td></tr>
     <tr><td>settingsRef</td><td>A reference to the ivy settings that must be used by this task <b>(since 2.0)</b></td><td>No, 'ivy.instance' is taken by default.</td></tr>
+    <tr><td>overwrite</td><td>Overwrite the value of the property if it already exist <b>(since 2.0)</b>.  Before 2.0, the properties were always overwritten.</td><td>No, 'false' by default.</td></tr>
 </tbody>
 </table>
 

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java?view=diff&rev=562392&r1=562391&r2=562392
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java Fri Aug  3 01:55:02 2007
@@ -33,6 +33,7 @@
     private String name;
 
     private String value;
+    private boolean overwrite = false;
 
     public String getName() {
         return this.name;
@@ -50,6 +51,12 @@
         this.value = value;
     }
 
+    
+    public void setOverwrite(boolean overwrite) {
+        this.overwrite  = overwrite;
+        
+    }
+    
     public void doExecute() throws BuildException {
         prepareAndCheck();
 
@@ -72,11 +79,19 @@
                         artifact, confs[i]);
                     String value = IvyPatternHelper.substitute(
                         getSettings().substitute(getValue()), artifact, confs[i]);
-                    getProject().setProperty(name, value);
+                    setProperty(name, value);
                 }
             }
         } catch (Exception ex) {
             throw new BuildException("impossible to add artifact properties: " + ex, ex);
+        }
+    }
+
+    private void setProperty(String name, String value) {
+        if (overwrite) {
+            getProject().setProperty(name, value);
+        } else {
+            getProject().setNewProperty(name,value);
         }
     }
 }