You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2006/12/07 19:24:14 UTC

svn commit: r483591 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Ant.java

Author: mbenson
Date: Thu Dec  7 10:24:13 2006
New Revision: 483591

URL: http://svn.apache.org/viewvc?view=rev&rev=483591
Log:
add protected newProject accessor.  Bugzilla 41127.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Ant.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Ant.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Ant.java?view=diff&rev=483591&r1=483590&r2=483591
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Ant.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Ant.java Thu Dec  7 10:24:13 2006
@@ -149,7 +149,8 @@
     }
 
     /**
-     * Called in execute or createProperty if newProject is null.
+     * Called in execute or createProperty (via getNewProject())
+     * if newProject is null.
      *
      * <p>This can happen if the same instance of this task is run
      * twice as newProject is set to null at the end of execute (to
@@ -311,9 +312,7 @@
         String savedAntFile = antFile;
         Vector locals = new Vector(targets);
         try {
-            if (newProject == null) {
-                reinit();
-            }
+            getNewProject();
 
             if (dir == null && inheritAll) {
                 dir = getProject().getBaseDir();
@@ -653,11 +652,8 @@
      * @return the created <code>Property</code> object.
      */
     public Property createProperty() {
-        if (newProject == null) {
-            reinit();
-        }
         Property p = new Property(true, getProject());
-        p.setProject(newProject);
+        p.setProject(getNewProject());
         p.setTaskName("property");
         properties.addElement(p);
         return p;
@@ -697,6 +693,18 @@
      */
     public void addPropertyset(PropertySet ps) {
         propertySets.addElement(ps);
+    }
+
+    /*
+     * Get the (sub)-Project instance currently in use.
+     * @return Project
+     * @since Ant 1.7
+     */
+    protected Project getNewProject() {
+        if (newProject == null) {
+            reinit();
+        }
+        return newProject;
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org