git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271300 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -155,8 +155,10 @@ public class ExecutionManager { | |||
| * @param targets a list of target names to be executed. | |||
| * @param commandProperties the properties defined by the front end to | |||
| * control the build | |||
| * @exception AntException if there is a problem in the build | |||
| */ | |||
| public void runBuild(Project project, List targets, Map commandProperties) { | |||
| public void runBuild(Project project, List targets, Map commandProperties) | |||
| throws AntException { | |||
| Throwable buildFailureCause = null; | |||
| try { | |||
| // start by validating the project we have been given. | |||
| @@ -178,6 +180,7 @@ public class ExecutionManager { | |||
| throw e; | |||
| } catch (AntException e) { | |||
| buildFailureCause = e; | |||
| throw e; | |||
| } finally { | |||
| eventSupport.fireBuildFinished(project, buildFailureCause); | |||
| } | |||
| @@ -221,6 +221,10 @@ public class Frame { | |||
| protected void setDataValue(String name, Object value, boolean mutable) | |||
| throws ExecutionException { | |||
| Frame frame = getContainingFrame(name); | |||
| if (frame == null) { | |||
| throw new ExecutionException("There is no project corresponding " | |||
| + "to the name \"" + name + "\""); | |||
| } | |||
| if (frame == this) { | |||
| if (dataValues.containsKey(name) && !mutable) { | |||
| log("Ignoring oveeride for data value " + name, | |||
| @@ -399,6 +403,10 @@ public class Frame { | |||
| */ | |||
| protected Object getDataValue(String name) throws ExecutionException { | |||
| Frame frame = getContainingFrame(name); | |||
| if (frame == null) { | |||
| throw new ExecutionException("There is no project corresponding " | |||
| + "to the name \"" + name + "\""); | |||
| } | |||
| if (frame == this) { | |||
| return dataValues.get(name); | |||
| } else { | |||
| @@ -417,6 +425,10 @@ public class Frame { | |||
| */ | |||
| protected boolean isDataValueSet(String name) throws ExecutionException { | |||
| Frame frame = getContainingFrame(name); | |||
| if (frame == null) { | |||
| throw new ExecutionException("There is no project corresponding " | |||
| + "to the name \"" + name + "\""); | |||
| } | |||
| if (frame == this) { | |||
| return dataValues.containsKey(name); | |||
| } else { | |||
| @@ -864,9 +876,6 @@ public class Frame { | |||
| private void createNestedElement(AntLibFactory factory, Setter setter, | |||
| Object element, BuildElement model) | |||
| throws ExecutionException { | |||
| log("The use of create methods is deprecated - class: " | |||
| + element.getClass().getName(), MessageLevel.MSG_INFO); | |||
| String nestedElementName = model.getType(); | |||
| try { | |||
| Object nestedElement | |||
| @@ -55,8 +55,8 @@ package org.apache.tools.ant; | |||
| import org.apache.ant.common.antlib.AntContext; | |||
| import org.apache.ant.common.antlib.Converter; | |||
| import org.apache.ant.common.antlib.StandardLibFactory; | |||
| import org.apache.ant.common.util.ExecutionException; | |||
| import org.apache.ant.common.service.EventService; | |||
| import org.apache.ant.common.util.ExecutionException; | |||
| import org.apache.ant.init.LoaderUtils; | |||
| /** | |||
| @@ -85,7 +85,7 @@ public class Ant1Factory extends StandardLibFactory { | |||
| if (project != null) { | |||
| return; | |||
| } | |||
| this.context = context; | |||
| // set the system classpath. In Ant2, the system classpath will not | |||
| // in general, have any useful information. For Ant1 compatability | |||
| @@ -94,8 +94,8 @@ public class Ant1Factory extends StandardLibFactory { | |||
| project = new Project(this); | |||
| project.init(context); | |||
| EventService eventService = | |||
| EventService eventService = | |||
| (EventService)context.getCoreService(EventService.class); | |||
| eventService.addBuildListener(project); | |||
| } | |||
| @@ -105,12 +105,13 @@ public class Ant1Factory extends StandardLibFactory { | |||
| * Create an instance of the requested type class | |||
| * | |||
| * @param typeClass the class from which an instance is required | |||
| * @param localName the name of the type within its library | |||
| * @return an instance of the requested class | |||
| * @exception ExecutionException the instance could not be created. | |||
| * @exception InstantiationException if the type cannot be instantiated | |||
| * @exception IllegalAccessException if the type cannot be accessed | |||
| */ | |||
| public Object createTypeInstance(Class typeClass) | |||
| public Object createTypeInstance(Class typeClass, String localName) | |||
| throws InstantiationException, IllegalAccessException, | |||
| ExecutionException { | |||
| try { | |||
| @@ -145,11 +146,12 @@ public class Ant1Factory extends StandardLibFactory { | |||
| * Create an instance of the requested task class | |||
| * | |||
| * @param taskClass the class from which an instance is required | |||
| * @param localName the name of the task within its library | |||
| * @return an instance of the requested class | |||
| * @exception InstantiationException if the task cannot be instantiated | |||
| * @exception IllegalAccessException if the task cannot be accessed | |||
| */ | |||
| public Object createTaskInstance(Class taskClass) | |||
| public Object createTaskInstance(Class taskClass, String localName) | |||
| throws InstantiationException, IllegalAccessException { | |||
| Object instance = taskClass.newInstance(); | |||
| if (instance instanceof ProjectComponent) { | |||
| @@ -72,9 +72,7 @@ import org.apache.ant.antcore.xml.ParseContext; | |||
| import org.apache.ant.antcore.xml.XMLParseException; | |||
| import org.apache.ant.common.event.BuildListener; | |||
| import org.apache.ant.common.model.Project; | |||
| import org.apache.ant.common.util.AntException; | |||
| import org.apache.ant.common.util.ConfigException; | |||
| import org.apache.ant.common.util.Location; | |||
| import org.apache.ant.common.event.MessageLevel; | |||
| import org.apache.ant.init.InitConfig; | |||
| import org.apache.ant.init.InitUtils; | |||
| @@ -297,27 +295,8 @@ public class Commandline { | |||
| addBuildListeners(executionManager); | |||
| executionManager.init(); | |||
| executionManager.runBuild(project, targets, definedProperties); | |||
| System.exit(0); | |||
| } catch (Throwable t) { | |||
| if (t instanceof AntException) { | |||
| AntException e = (AntException)t; | |||
| Location location = e.getLocation(); | |||
| Throwable cause = e.getCause(); | |||
| if (location != null && location != Location.UNKNOWN_LOCATION) { | |||
| System.out.print(location); | |||
| } | |||
| System.out.println(e.getMessage()); | |||
| if (messageOutputLevel >= MessageLevel.MSG_VERBOSE) { | |||
| t.printStackTrace(); | |||
| } | |||
| if (cause != null) { | |||
| System.out.println("Root cause: " + cause.toString()); | |||
| } | |||
| } else { | |||
| t.printStackTrace(System.err); | |||
| } | |||
| System.exit(1); | |||
| } | |||
| } | |||