From 6d157f462cdd9e601cb6fd296cb8c746ed7227fc Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Fri, 6 Jul 2001 11:57:29 +0000 Subject: [PATCH] Add inheritAll attribute to task Submitted by: Craeg K Strong git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269275 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/Ant.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java index 7c6227f47..20ab62d92 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Ant.java +++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java @@ -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); } }