ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant Project.java
Date Thu, 26 May 2005 17:01:01 GMT
mbenson     2005/05/26 10:01:01

  Modified:    src/main/org/apache/tools/ant/taskdefs Ant.java
               src/main/org/apache/tools/ant Project.java
  Log:
  Obtain subproject instance from Project to satisfy the remote chance
  of Project having been subclassed.
  PR: 17901
  
  Revision  Changes    Path
  1.122     +1 -5      ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
  
  Index: Ant.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
  retrieving revision 1.121
  retrieving revision 1.122
  diff -u -r1.121 -r1.122
  --- Ant.java	25 May 2005 22:25:43 -0000	1.121
  +++ Ant.java	26 May 2005 17:01:01 -0000	1.122
  @@ -143,8 +143,7 @@
        * Creates a Project instance for the project to call.
        */
       public void init() {
  -        newProject = new Project();
  -        newProject.setDefaultInputStream(getProject().getDefaultInputStream());
  +        newProject = getProject().createSubProject();
           newProject.setJavaVersionProperty();
       }
   
  @@ -194,9 +193,6 @@
                   log("Ant: Can't set output to " + output);
               }
           }
  -
  -        getProject().initSubProject(newProject);
  -
           // set user-defined properties
           getProject().copyUserProperties(newProject);
   
  
  
  
  1.192     +20 -1     ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.191
  retrieving revision 1.192
  diff -u -r1.191 -r1.192
  --- Project.java	7 Apr 2005 19:31:39 -0000	1.191
  +++ Project.java	26 May 2005 17:01:01 -0000	1.192
  @@ -235,12 +235,31 @@
       }
   
       /**
  -     * Init a sub project--used by taskdefs.Ant .
  +     * Create and initialize a subproject. By default the subproject will be of
  +     * the same type as its parent. If a no-arg constructor is unavailable, the
  +     * <code>Project</code> class will be used.
  +     * @return a Project instance configured as a subproject of this Project.
  +     * @since Ant 1.7
  +     */
  +    public Project createSubProject() {
  +        Project subProject = null;
  +        try {
  +            subProject = (Project) (getClass().newInstance());
  +        } catch (Exception e) {
  +            subProject = new Project();
  +        }
  +        initSubProject(subProject);
  +        return subProject;
  +    }
  +
  +    /**
  +     * Initialize a subproject.
        * @param subProject the subproject to initialize.
        */
       public void initSubProject(Project subProject) {
           ComponentHelper.getComponentHelper(subProject)
               .initSubProject(ComponentHelper.getComponentHelper(this));
  +        subProject.setDefaultInputStream(getDefaultInputStream());
           subProject.setKeepGoingMode(this.isKeepGoingMode());
           subProject.setExecutor(getExecutor().getSubProjectExecutor());
       }
  
  
  

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


Mime
View raw message