You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by co...@apache.org on 2001/07/06 13:57:34 UTC

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

conor       01/07/06 04:57:33

  Modified:    src/main/org/apache/tools/ant/taskdefs Ant.java
  Log:
  Add inheritAll attribute to <ant> task
  
  Submitted by:	Craeg K Strong <cs...@arielpartners.com>
  
  Revision  Changes    Path
  1.23      +24 -4     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
  
  Index: Ant.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Ant.java	2001/03/12 09:22:04	1.22
  +++ Ant.java	2001/07/06 11:57:29	1.23
  @@ -83,10 +83,20 @@
       private String antFile = null;
       private String target = null;
       private String output = null;
  +    private boolean inheritAll = true;
   
  -    Vector properties=new Vector();
  +    Vector properties = new Vector();
       Project p1;
   
  +    /**
  +     * If true, inherit all properties from parent Project
  +     * If false, inherit only userProperties and those defined
  +     * inside the ant call itself
  +     **/
  +    public void setInheritAll(boolean inherit) {
  +       inheritAll = inherit;
  +    } //-- setInheritAll
  +
       public void init() {
           p1 = new Project();
           p1.setJavaVersionProperty();
  @@ -149,13 +159,23 @@
               p1.addDataTypeDefinition(typeName, typeClass);
           }
   
  -        // set user-define properties
  -        Hashtable prop1 = project.getProperties();
  +        // set user-defined or all properties from calling project
  +        Hashtable prop1;
  +        if (inheritAll == true) {
  +           prop1 = project.getProperties();
  +        }
  +        else {
  +           prop1 = project.getUserProperties();
  +        }
  +        
           e = prop1.keys();
           while (e.hasMoreElements()) {
               String arg = (String) e.nextElement();
               String value = (String) prop1.get(arg);
  -            p1.setProperty(arg, value);
  +            if (inheritAll == true)
  +               p1.setProperty(arg, value);
  +            else
  +               p1.setUserProperty(arg, value);
           }
       }