Home » apache-ant-1.7.1-src » org.apache.tools » ant » helper » [javadoc | source]
    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    *
   17    */
   18   
   19   package org.apache.tools.ant.helper;
   20   
   21   import org.apache.tools.ant.Project;
   22   import org.apache.tools.ant.Executor;
   23   import org.apache.tools.ant.BuildException;
   24   
   25   /**
   26    * Default Target executor implementation. Runs each target individually
   27    * (including all of its dependencies). If an error occurs, behavior is
   28    * determined by the Project's "keep-going" mode.
   29    * @since Ant 1.6.3
   30    */
   31   public class DefaultExecutor implements Executor {
   32   
   33       private static final SingleCheckExecutor SUB_EXECUTOR = new SingleCheckExecutor();
   34   
   35       /** {@inheritDoc}. */
   36       public void executeTargets(Project project, String[] targetNames)
   37           throws BuildException {
   38           BuildException thrownException = null;
   39           for (int i = 0; i < targetNames.length; i++) {
   40               try {
   41                   project.executeTarget(targetNames[i]);
   42               } catch (BuildException ex) {
   43                   if (project.isKeepGoingMode()) {
   44                       thrownException = ex;
   45                   } else {
   46                       throw ex;
   47                   }
   48               }
   49           }
   50           if (thrownException != null) {
   51               throw thrownException;
   52           }
   53       }
   54   
   55       /** {@inheritDoc}. */
   56       public Executor getSubProjectExecutor() {
   57           return SUB_EXECUTOR;
   58       }
   59   
   60   }

Save This Page
Home » apache-ant-1.7.1-src » org.apache.tools » ant » helper » [javadoc | source]