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/helper DefaultExecutor.java KeepGoingExecutor.java SingleCheckExecutor.java
Date Tue, 31 Aug 2004 22:32:53 GMT
mbenson     2004/08/31 15:32:53

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant Project.java
               docs/manual running.html
               src/main/org/apache/tools/ant/taskdefs Ant.java
  Added:       src/main/org/apache/tools/ant Executor.java
               src/main/org/apache/tools/ant/helper DefaultExecutor.java
                        KeepGoingExecutor.java SingleCheckExecutor.java
  Log:
  Refactored Target invocation into org.apache.tools.ant.Executor
  implementations.
  PR: 21421, 29248
  
  Revision  Changes    Path
  1.656     +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.655
  retrieving revision 1.656
  diff -u -r1.655 -r1.656
  --- WHATSNEW	31 Aug 2004 22:24:39 -0000	1.655
  +++ WHATSNEW	31 Aug 2004 22:32:51 -0000	1.656
  @@ -44,6 +44,9 @@
     Compilers can be selected using the compiler attribute, which defaults
     to "microsoft" on windows, and "mono" on everything else.
   
  +* Refactored Target invocation into org.apache.tools.ant.Executor
  +  implementations.  Bugzilla Reports 21421, 29248.
  +
   Changes from Ant 1.6.2 to current Ant 1.6 CVS version
   =====================================================
   
  
  
  
  1.173     +37 -12    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.172
  retrieving revision 1.173
  diff -u -r1.172 -r1.173
  --- Project.java	23 Jul 2004 20:16:29 -0000	1.172
  +++ Project.java	31 Aug 2004 22:32:52 -0000	1.173
  @@ -33,6 +33,8 @@
   import java.util.HashSet;
   import org.apache.tools.ant.input.DefaultInputHandler;
   import org.apache.tools.ant.input.InputHandler;
  +import org.apache.tools.ant.helper.DefaultExecutor;
  +import org.apache.tools.ant.helper.KeepGoingExecutor;
   import org.apache.tools.ant.types.FilterSet;
   import org.apache.tools.ant.types.FilterSetCollection;
   import org.apache.tools.ant.types.Description;
  @@ -764,7 +766,9 @@
       /**
        * Sets "keep-going" mode. In this mode ANT will try to execute
        * as many targets as possible. All targets that do not depend
  -     * on failed target(s) will be executed.
  +     * on failed target(s) will be executed.  If the keepGoing settor/getter
  +     * methods are used in conjunction with the <code>ant.executor.class</code>
  +     * property, they will have no effect.
        * @param keepGoingMode "keep-going" mode
        * @since Ant 1.6
        */
  @@ -773,7 +777,9 @@
       }
   
       /**
  -     * Returns the keep-going mode.
  +     * Returns the keep-going mode.  If the keepGoing settor/getter
  +     * methods are used in conjunction with the <code>ant.executor.class</code>
  +     * property, they will have no effect.
        * @return "keep-going" mode
        * @since Ant 1.6
        */
  @@ -1054,19 +1060,38 @@
        */
       public void executeTargets(Vector targetNames) throws BuildException {
   
  -        BuildException thrownException = null;
  -        for (int i = 0; i < targetNames.size(); i++) {
  +        Object o = getReference("ant.executor");
  +        if (o == null) {
  +            String classname = getProperty("ant.executor.class");
  +            if (classname == null) {
  +                classname = (keepGoingMode)
  +                    ? KeepGoingExecutor.class.getName()
  +                    : DefaultExecutor.class.getName();
  +            }
  +            log("Attempting to create object of type " + classname, MSG_DEBUG);
               try {
  -                executeTarget((String) targetNames.elementAt(i));
  -            } catch (BuildException ex) {
  -                if (!(keepGoingMode)) {
  -                    throw ex; // Throw further
  +                o = Class.forName(classname, true, coreLoader).newInstance();
  +            } catch (ClassNotFoundException seaEnEfEx) {
  +                //try the current classloader
  +                try {
  +                    o = Class.forName(classname).newInstance();
  +                } catch (Exception ex) {
  +                    log(ex.toString(), MSG_ERR);
                   }
  -                thrownException = ex;
  +            } catch (Exception ex) {
  +                log(ex.toString(), MSG_ERR);
  +            }
  +            if (o != null) {
  +                addReference("ant.executor", o);
               }
           }
  -        if (thrownException != null) {
  -            throw thrownException;
  +
  +        if (o == null) {
  +            throw new BuildException("Unable to obtain a Target Executor instance.");
  +        } else {
  +            String[] targetNameArray = (String[])(targetNames.toArray(
  +                new String[targetNames.size()]));
  +            ((Executor)o).executeTargets(this, targetNameArray);
           }
       }
   
  
  
  
  1.1                  ant/src/main/org/apache/tools/ant/Executor.java
  
  Index: Executor.java
  ===================================================================
  /*
   * Copyright 2004 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.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   */
  
  package org.apache.tools.ant;
  
  /**
   * Target executor abstraction.
   * @since Ant 1.6.3
   */
  public interface Executor {
  
      /**
       * Execute the specified Targets for the specified Project.
       * @param project       the Ant Project.
       * @param targetNames   String[] of Target names.
       * @throws BuildException.
       */
      void executeTargets(Project project, String[] targetNames)
          throws BuildException;
  }
  
  
  
  1.27      +8 -1      ant/docs/manual/running.html
  
  Index: running.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/running.html,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- running.html	9 Feb 2004 21:50:05 -0000	1.26
  +++ running.html	31 Aug 2004 22:32:53 -0000	1.27
  @@ -230,6 +230,13 @@
     <th>description</th>
   </tr>
   <tr>
  +  <td><code>ant.executor.class</code></td>
  +  <td>classname; default is org.apache.tools.ant.helper.DefaultExecutor</td>
  +  <td><b>Since Ant 1.6.3</b> Ant will delegate Target invocation to the
  +org.apache.tools.ant.Executor implementation specified here.
  +  </td>
  +</tr>
  +<tr>
     <td><code>ant.input.properties</code></td>
     <td>filename (required)</td>
     <td>Name of the file holding the values for the
  @@ -473,4 +480,4 @@
   Reserved.</p>
   
   </body>
  -</html>
  \ No newline at end of file
  +</html>
  
  
  
  1.106     +6 -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.105
  retrieving revision 1.106
  diff -u -r1.105 -r1.106
  --- Ant.java	23 Jul 2004 20:16:29 -0000	1.105
  +++ Ant.java	31 Aug 2004 22:32:53 -0000	1.106
  @@ -36,6 +36,7 @@
   import org.apache.tools.ant.ProjectHelper;
   import org.apache.tools.ant.Target;
   import org.apache.tools.ant.Task;
  +import org.apache.tools.ant.helper.SingleCheckExecutor;
   import org.apache.tools.ant.types.PropertySet;
   import org.apache.tools.ant.util.FileUtils;
   
  @@ -62,6 +63,9 @@
    */
   public class Ant extends Task {
   
  +    /** Target Executor */
  +    private static SingleCheckExecutor executor = new SingleCheckExecutor();
  +
       /** the basedir where is executed the build file */
       private File dir = null;
   
  @@ -394,11 +398,8 @@
                   try {
                       log("Entering " + antFile + "...", Project.MSG_VERBOSE);
                       newProject.fireSubBuildStarted();
  -                    String[] nameArray =
  -                        (String[])(locals.toArray(new String[locals.size()]));
  -
  -                    newProject.executeSortedTargets(newProject.topoSort(
  -                        nameArray, newProject.getTargets(), false));
  +                    executor.executeTargets(newProject,
  +                        (String[])(locals.toArray(new String[locals.size()])));
   
                   } catch (BuildException ex) {
                       t = ProjectHelper
  
  
  
  1.1                  ant/src/main/org/apache/tools/ant/helper/DefaultExecutor.java
  
  Index: DefaultExecutor.java
  ===================================================================
  /*
   * Copyright 2004 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.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   */
  
  package org.apache.tools.ant.helper;
  
  
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Executor;
  import org.apache.tools.ant.BuildException;
  
  
  /**
   * Default Target executor implementation.
   * @since Ant 1.6.3
   */
  public class DefaultExecutor implements Executor {
  
      //inherit doc
      public void executeTargets(Project project, String[] targetNames)
          throws BuildException {
          for (int i = 0; i < targetNames.length; i++) {
              project.executeTarget(targetNames[i]);
          }
      }
  
  }
  
  
  
  1.1                  ant/src/main/org/apache/tools/ant/helper/KeepGoingExecutor.java
  
  Index: KeepGoingExecutor.java
  ===================================================================
  /*
   * Copyright 2004 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.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   */
  
  package org.apache.tools.ant.helper;
  
  
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Executor;
  import org.apache.tools.ant.BuildException;
  
  
  /**
   * "Keep-going" Target executor implementation.
   * @since Ant 1.6.3
   */
  public class KeepGoingExecutor implements Executor {
  
      //inherit doc
      public void executeTargets(Project project, String[] targetNames)
          throws BuildException {
          BuildException thrownException = null;
          for (int i = 0; i < targetNames.length; i++) {
              try {
                  project.executeTarget(targetNames[i]);
              } catch (BuildException ex) {
                  thrownException = ex;
              }
          }
          if (thrownException != null) {
              throw thrownException;
          }
      }
  
  }
  
  
  
  1.1                  ant/src/main/org/apache/tools/ant/helper/SingleCheckExecutor.java
  
  Index: SingleCheckExecutor.java
  ===================================================================
  /*
   * Copyright 2004 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.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   */
  
  package org.apache.tools.ant.helper;
  
  
  import java.util.Vector;
  
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Executor;
  import org.apache.tools.ant.BuildException;
  
  
  /**
   * "Single-check" Target executor implementation.
   * @since Ant 1.6.3
   */
  public class SingleCheckExecutor implements Executor {
  
      //inherit doc
      public void executeTargets(Project project, String[] targetNames)
          throws BuildException {
              project.executeSortedTargets(
                  project.topoSort(targetNames, project.getTargets(), false));
      }
  
  }
  
  
  

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


Mime
View raw message