Index: src/main/org/apache/tools/ant/taskdefs/Ant.java =================================================================== --- src/main/org/apache/tools/ant/taskdefs/Ant.java (revision 424540) +++ src/main/org/apache/tools/ant/taskdefs/Ant.java (working copy) @@ -1,5 +1,5 @@ /* - * Copyright 2000-2005 The Apache Software Foundation + * Copyright 2000-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.ProjectHelper; +import org.apache.tools.ant.PropertyHelper; import org.apache.tools.ant.Target; import org.apache.tools.ant.Task; import org.apache.tools.ant.MagicNames; @@ -140,6 +141,52 @@ } /** + * Creates a clone of the property helper + * if inheritAll is true. + */ + private void correctPropertyHelper() { + // A new attribute inheritPropertyHelper or similar + // would be better. With default = false would + // be fully backward compatible. Using inheritAll + // instead causes problems to subclasses of + // PropertyHelper which don't expect to be cloned + // in the subbuild. Hopefully they don't exist. + if (!inheritAll) { + // not cloning the property helper + return; + } + PropertyHelper thisHelper = (PropertyHelper) getProject() + .getReference(MagicNames.REFID_PROPERTY_HELPER); + if (thisHelper == null) { + // no helper to clone + return; + } + + PropertyHelper newHelper = null; + try { + newHelper = (PropertyHelper)thisHelper.clone(); + } catch (CloneNotSupportedException cnse) { + //log("Couln't clone PropertyHelper", Project.MSG_VERBOSE); + } + if (newHelper != null) { + PropertyHelper tempHelper + = PropertyHelper.getPropertyHelper(newProject); + newProject.addReference(MagicNames.REFID_PROPERTY_HELPER + , newHelper); + // steal the properties + tempHelper.copyInheritedProperties(newProject); + tempHelper.copyUserProperties(newProject); + Hashtable props = tempHelper.getProperties(); + Enumeration e = props.keys(); + while (e.hasMoreElements()) { + String name = e.nextElement().toString(); + Object value = props.get(name); + newProject.setNewProperty(name, value.toString()); + } + } + } + + /** * Creates a Project instance for the project to call. */ public void init() { @@ -286,6 +333,7 @@ if (newProject == null) { reinit(); } + correctPropertyHelper(); if ((dir == null) && (inheritAll)) { dir = getProject().getBaseDir();