You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by ru...@locus.apache.org on 2000/05/28 00:21:10 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Property.java

rubys       00/05/27 15:21:10

  Modified:    src/main/org/apache/tools/ant Project.java
               src/main/org/apache/tools/ant/taskdefs Property.java
  Log:
  Make sure that properies from the command line and/or parent projects
  override properties specified in the build.xml file.
  
  Revision  Changes    Path
  1.20      +6 -0      jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Project.java	2000/04/28 08:45:21	1.19
  +++ Project.java	2000/05/27 22:21:09	1.20
  @@ -198,6 +198,12 @@
           return property;
       }
   
  +    public String getUserProperty(String name) {
  +        if (name == null) return null;
  +        String property = (String) userProperties.get(name);
  +        return property;
  +    }
  +
       public Hashtable getProperties() {
           return properties;
       }
  
  
  
  1.5       +27 -5     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java
  
  Index: Property.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Property.java	2000/02/23 20:46:53	1.4
  +++ Property.java	2000/05/27 22:21:10	1.5
  @@ -60,8 +60,10 @@
   
   /**
    * Will set a Project property. Used to be a hack in ProjectHelper
  + * Will not override values set by the command line or parent projects.
    *
    * @author costin@dnt.ro
  + * @author Sam Ruby <ru...@us.ibm.com>
    */
   public class Property extends Task {
   
  @@ -101,9 +103,19 @@
               if ((name != null) && (value != null)) {
                   String v = ProjectHelper.replaceProperties(value, project.getProperties());
   		if( userProperty )
  -		    project.setUserProperty(name, v);
  +                    if (project.getUserProperty(name) == null) {
  +		        project.setUserProperty(name, v);
  +                    } else {
  +                        project.log("Override ignored for " + name, 
  +                                    project.MSG_VERBOSE);
  +                    }
   		else
  -		    project.setProperty(name, v);
  +                    if (project.getProperty(name) == null) {
  +		        project.setProperty(name, v);
  +                    } else {
  +                        project.log("Override ignored for " + name, 
  +                                    project.MSG_VERBOSE);
  +                    }
               }
   
               if (file != null) loadFile(file);
  @@ -149,9 +161,19 @@
               String value = (String) props.getProperty(name);
               String v = ProjectHelper.replaceProperties(value, project.getProperties());
               if( userProperty )
  -		project.setUserProperty(name, v);
  -	    else
  -		project.setProperty(name, v);
  +                if (project.getUserProperty(name) == null) {
  +		    project.setUserProperty(name, v);
  +                } else {
  +                    project.log("Override ignored for " + name, 
  +                                project.MSG_VERBOSE);
  +                }
  +            else
  +                if (project.getProperty(name) == null) {
  +		    project.setProperty(name, v);
  +                } else {
  +                    project.log("Override ignored for " + name, 
  +                                project.MSG_VERBOSE);
  +                }
           }
       }
   
  
  
  

Re: Available task status and question

Posted by Bill Barnhill <bb...@twcny.rr.com>.
Status:
The AvailableEx task will be done by end of weekend. Named AvailableEx
for now, because it is not really an extension of Available but a task
that does what Available does in a different way.  This can handle
anything Available can, but also handles checking for multiple files,
resources, and classes.  Added one item to core file ProjectHelper, an
invocation of setGeneric(String attr, String value) if that method
exists in the task and no setter for the current attribute is found.
AvailableEx treats any attribute coming in this way as a list of items
to check availability of.  The attribute name is used to get the class
to actually do the check and if the class is in the classpath it is
used (if not a warning is logged and that attribute ignored).  Any
check can have one item or a comma delimited list of items.  Also it
maintains a count of checked and found items and will set the property
depending on which case occurs : All items found, No items found, more
found than not, more not found than were.  The value to set the
property to is settable for each case and defaults to
true,false,false,false respectively.  I'll post several examples when
I post the files.

Question:
Ithought Ant was designed for jdk1.2.x and greater and then I saw
where it checks the version and only says ant is incompatible if
version is 1.0.  I am currently using the jdk1.2 Collection API and
would like to keep using it, but if I have to maintain total
compatibility with 1.1.x  then I should probably convert my code to
use the 1.1 classes only and not take advantage of the new API.

There is a question in there...Can I use 1.2 or higher classes in ant,
or only 1.1 compatible?

Thanks in advance,
Bill Barnhill