View | Details | Raw Unified | Return to bug 40093
Collapse All | Expand All

(-)src/main/org/apache/tools/ant/taskdefs/Ant.java (-1 / +49 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * Copyright  2000-2005 The Apache Software Foundation
2
 * Copyright  2000-2006 The Apache Software Foundation
3
 *
3
 *
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
5
 *  you may not use this file except in compliance with the License.
5
 *  you may not use this file except in compliance with the License.
Lines 34-39 Link Here
34
import org.apache.tools.ant.Project;
34
import org.apache.tools.ant.Project;
35
import org.apache.tools.ant.ProjectComponent;
35
import org.apache.tools.ant.ProjectComponent;
36
import org.apache.tools.ant.ProjectHelper;
36
import org.apache.tools.ant.ProjectHelper;
37
import org.apache.tools.ant.PropertyHelper;
37
import org.apache.tools.ant.Target;
38
import org.apache.tools.ant.Target;
38
import org.apache.tools.ant.Task;
39
import org.apache.tools.ant.Task;
39
import org.apache.tools.ant.MagicNames;
40
import org.apache.tools.ant.MagicNames;
Lines 140-145 Link Here
140
    }
141
    }
141
142
142
    /**
143
    /**
144
     * Creates a clone of the property helper 
145
     * if <var>inheritAll</var> is <code>true</code>.
146
      */
147
    private void correctPropertyHelper() {
148
        // A new attribute inheritPropertyHelper or similar
149
        // would be better. With default = false would
150
        // be fully backward compatible. Using inheritAll
151
        // instead causes problems to subclasses of
152
        // PropertyHelper which don't expect to be cloned
153
        // in the subbuild. Hopefully they don't exist.
154
        if (!inheritAll) {
155
            // not cloning the property helper
156
            return;
157
        }
158
        PropertyHelper thisHelper = (PropertyHelper) getProject()
159
                .getReference(MagicNames.REFID_PROPERTY_HELPER);
160
        if (thisHelper == null) {
161
            // no helper to clone
162
            return;
163
        }
164
165
        PropertyHelper newHelper = null;
166
        try {
167
            newHelper = (PropertyHelper)thisHelper.clone();
168
        } catch (CloneNotSupportedException cnse) {
169
            //log("Couln't clone PropertyHelper", Project.MSG_VERBOSE);
170
        }
171
        if (newHelper != null) {
172
            PropertyHelper tempHelper 
173
                = PropertyHelper.getPropertyHelper(newProject);
174
            newProject.addReference(MagicNames.REFID_PROPERTY_HELPER
175
                    , newHelper);
176
            // steal the properties
177
            tempHelper.copyInheritedProperties(newProject);
178
            tempHelper.copyUserProperties(newProject);
179
            Hashtable props = tempHelper.getProperties();
180
            Enumeration e = props.keys();
181
            while (e.hasMoreElements()) {
182
                String name = e.nextElement().toString();
183
                Object value = props.get(name);
184
                newProject.setNewProperty(name, value.toString());
185
            }
186
        }
187
    }
188
189
    /**
143
     * Creates a Project instance for the project to call.
190
     * Creates a Project instance for the project to call.
144
     */
191
     */
145
    public void init() {
192
    public void init() {
Lines 286-291 Link Here
286
            if (newProject == null) {
333
            if (newProject == null) {
287
                reinit();
334
                reinit();
288
            }
335
            }
336
            correctPropertyHelper();
289
337
290
            if ((dir == null) && (inheritAll)) {
338
            if ((dir == null) && (inheritAll)) {
291
                dir = getProject().getBaseDir();
339
                dir = getProject().getBaseDir();

Return to bug 40093