mbenson 2005/04/07 13:14:52 Modified: src/main/org/apache/tools/ant/helper Tag: ANT_16_BRANCH DefaultExecutor.java SingleCheckExecutor.java src/main/org/apache/tools/ant Tag: ANT_16_BRANCH Executor.java Project.java src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH Ant.java Added: src/etc/testcases/core Tag: ANT_16_BRANCH executor.xml src/testcases/org/apache/tools/ant Tag: ANT_16_BRANCH ExecutorTest.java Removed: src/main/org/apache/tools/ant/helper Tag: ANT_16_BRANCH KeepGoingExecutor.java Log: Merge Executor mods for 1.6.3 . Revision Changes Path No revision No revision 1.1.2.1 +0 -0 ant/src/etc/testcases/core/executor.xml No revision No revision 1.1.2.1 +0 -0 ant/src/testcases/org/apache/tools/ant/ExecutorTest.java No revision No revision 1.3.2.2 +23 -5 ant/src/main/org/apache/tools/ant/helper/DefaultExecutor.java Index: DefaultExecutor.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/helper/DefaultExecutor.java,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -r1.3.2.1 -r1.3.2.2 --- DefaultExecutor.java 14 Dec 2004 23:48:01 -0000 1.3.2.1 +++ DefaultExecutor.java 7 Apr 2005 20:14:52 -0000 1.3.2.2 @@ -1,5 +1,5 @@ /* - * Copyright 2004 The Apache Software Foundation + * Copyright 2004-2005 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. @@ -17,25 +17,43 @@ 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. Runs each target individually - * (including all of its dependencies), halting immediately upon error. + * (including all of its dependencies). If an error occurs, behavior is + * determined by the Project's "keep-going" mode. * @since Ant 1.6.3 */ public class DefaultExecutor implements Executor { + private static final SingleCheckExecutor SUB_EXECUTOR = new SingleCheckExecutor(); + //inherit doc public void executeTargets(Project project, String[] targetNames) throws BuildException { + BuildException thrownException = null; for (int i = 0; i < targetNames.length; i++) { - project.executeTarget(targetNames[i]); + try { + project.executeTarget(targetNames[i]); + } catch (BuildException ex) { + if (project.isKeepGoingMode()) { + thrownException = ex; + } else { + throw ex; + } + } + } + if (thrownException != null) { + throw thrownException; } } + //inherit doc + public Executor getSubProjectExecutor() { + return SUB_EXECUTOR; + } + } 1.2.2.2 +6 -3 ant/src/main/org/apache/tools/ant/helper/SingleCheckExecutor.java Index: SingleCheckExecutor.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/helper/SingleCheckExecutor.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- SingleCheckExecutor.java 14 Dec 2004 23:48:01 -0000 1.2.2.1 +++ SingleCheckExecutor.java 7 Apr 2005 20:14:52 -0000 1.2.2.2 @@ -1,5 +1,5 @@ /* - * Copyright 2004 The Apache Software Foundation + * Copyright 2004-2005 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. @@ -18,8 +18,6 @@ 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; @@ -40,4 +38,9 @@ project.topoSort(targetNames, project.getTargets(), false)); } + //inherit doc + public Executor getSubProjectExecutor() { + return this; + } + } No revision No revision 1.2.2.2 +8 -1 ant/src/main/org/apache/tools/ant/Executor.java Index: Executor.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Executor.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- Executor.java 14 Dec 2004 23:48:00 -0000 1.2.2.1 +++ Executor.java 7 Apr 2005 20:14:52 -0000 1.2.2.2 @@ -1,5 +1,5 @@ /* - * Copyright 2004 The Apache Software Foundation + * Copyright 2004-2005 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. @@ -31,4 +31,11 @@ */ void executeTargets(Project project, String[] targetNames) throws BuildException; + + /** + * Get the appropriate subproject Executor instance. + * @return an Executor instance. + */ + Executor getSubProjectExecutor(); + } 1.154.2.18 +31 -21 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.154.2.17 retrieving revision 1.154.2.18 diff -u -r1.154.2.17 -r1.154.2.18 --- Project.java 9 Mar 2005 18:56:30 -0000 1.154.2.17 +++ Project.java 7 Apr 2005 20:14:52 -0000 1.154.2.18 @@ -35,7 +35,6 @@ import org.apache.tools.ant.input.InputHandler; import org.apache.tools.ant.loader.AntClassLoader2; 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; @@ -243,6 +242,7 @@ ComponentHelper.getComponentHelper(subProject) .initSubProject(ComponentHelper.getComponentHelper(this)); subProject.setKeepGoingMode(this.isKeepGoingMode()); + subProject.setExecutor(getExecutor().getSubProjectExecutor()); } /** @@ -1015,23 +1015,23 @@ } /** - * Execute the specified sequence of targets, and the targets - * they depend on. - * - * @param targetNames A vector of target name strings to execute. - * Must not be <code>null</code>. - * - * @exception BuildException if the build failed. + * Set the Executor instance for this Project. + * @param e the Executor to use. */ - public void executeTargets(Vector targetNames) throws BuildException { + public void setExecutor(Executor e) { + addReference("ant.executor", e); + } + /** + * Get this Project's Executor (setting it if necessary). + * @return an Executor instance. + */ + public Executor getExecutor() { 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(); + classname = DefaultExecutor.class.getName(); } log("Attempting to create object of type " + classname, MSG_DEBUG); try { @@ -1046,17 +1046,27 @@ } catch (Exception ex) { log(ex.toString(), MSG_ERR); } - if (o != null) { - addReference("ant.executor", o); + if (o == null) { + throw new BuildException( + "Unable to obtain a Target Executor instance."); } + setExecutor((Executor) o); } - 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); - } + return (Executor) o; + } + + /** + * Execute the specified sequence of targets, and the targets + * they depend on. + * + * @param names A vector of target name strings to execute. + * Must not be <code>null</code>. + * + * @exception BuildException if the build failed. + */ + public void executeTargets(Vector names) throws BuildException { + getExecutor().executeTargets(this, + (String[]) (names.toArray(new String[names.size()]))); } /** No revision No revision 1.92.2.12 +2 -7 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.92.2.11 retrieving revision 1.92.2.12 diff -u -r1.92.2.11 -r1.92.2.12 --- Ant.java 22 Dec 2004 09:47:56 -0000 1.92.2.11 +++ Ant.java 7 Apr 2005 20:14:52 -0000 1.92.2.12 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2004 The Apache Software Foundation + * Copyright 2000-2005 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. @@ -64,9 +64,6 @@ */ public class Ant extends Task { - /** Target Executor */ - private static final Executor EXECUTOR = new SingleCheckExecutor(); - /** the basedir where is executed the build file */ private File dir = null; @@ -382,9 +379,7 @@ try { log("Entering " + antFile + "...", Project.MSG_VERBOSE); newProject.fireSubBuildStarted(); - EXECUTOR.executeTargets(newProject, - (String[]) (locals.toArray(new String[locals.size()]))); - + newProject.executeTargets(locals); } catch (BuildException ex) { t = ProjectHelper .addLocationToBuildException(ex, getLocation());
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]