Browse Source

Add inheritAll attribute to <ant> task

Submitted by:	Craeg K Strong <cstrong@arielpartners.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269275 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
6d157f462c
1 changed files with 24 additions and 4 deletions
  1. +24
    -4
      src/main/org/apache/tools/ant/taskdefs/Ant.java

+ 24
- 4
src/main/org/apache/tools/ant/taskdefs/Ant.java View File

@@ -83,10 +83,20 @@ public class Ant extends Task {
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 @@ public class Ant extends Task {
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);
}
}



Loading…
Cancel
Save