Browse Source

Changes resulting from first run of gump with mutant

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271300 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
99dc457c6f
4 changed files with 25 additions and 32 deletions
  1. +4
    -1
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionManager.java
  2. +12
    -3
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
  3. +8
    -6
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Factory.java
  4. +1
    -22
      proposal/mutant/src/java/cli/org/apache/ant/cli/Commandline.java

+ 4
- 1
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionManager.java View File

@@ -155,8 +155,10 @@ public class ExecutionManager {
* @param targets a list of target names to be executed. * @param targets a list of target names to be executed.
* @param commandProperties the properties defined by the front end to * @param commandProperties the properties defined by the front end to
* control the build * 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; Throwable buildFailureCause = null;
try { try {
// start by validating the project we have been given. // start by validating the project we have been given.
@@ -178,6 +180,7 @@ public class ExecutionManager {
throw e; throw e;
} catch (AntException e) { } catch (AntException e) {
buildFailureCause = e; buildFailureCause = e;
throw e;
} finally { } finally {
eventSupport.fireBuildFinished(project, buildFailureCause); eventSupport.fireBuildFinished(project, buildFailureCause);
} }


+ 12
- 3
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java View File

@@ -221,6 +221,10 @@ public class Frame {
protected void setDataValue(String name, Object value, boolean mutable) protected void setDataValue(String name, Object value, boolean mutable)
throws ExecutionException { throws ExecutionException {
Frame frame = getContainingFrame(name); Frame frame = getContainingFrame(name);
if (frame == null) {
throw new ExecutionException("There is no project corresponding "
+ "to the name \"" + name + "\"");
}
if (frame == this) { if (frame == this) {
if (dataValues.containsKey(name) && !mutable) { if (dataValues.containsKey(name) && !mutable) {
log("Ignoring oveeride for data value " + name, log("Ignoring oveeride for data value " + name,
@@ -399,6 +403,10 @@ public class Frame {
*/ */
protected Object getDataValue(String name) throws ExecutionException { protected Object getDataValue(String name) throws ExecutionException {
Frame frame = getContainingFrame(name); Frame frame = getContainingFrame(name);
if (frame == null) {
throw new ExecutionException("There is no project corresponding "
+ "to the name \"" + name + "\"");
}
if (frame == this) { if (frame == this) {
return dataValues.get(name); return dataValues.get(name);
} else { } else {
@@ -417,6 +425,10 @@ public class Frame {
*/ */
protected boolean isDataValueSet(String name) throws ExecutionException { protected boolean isDataValueSet(String name) throws ExecutionException {
Frame frame = getContainingFrame(name); Frame frame = getContainingFrame(name);
if (frame == null) {
throw new ExecutionException("There is no project corresponding "
+ "to the name \"" + name + "\"");
}
if (frame == this) { if (frame == this) {
return dataValues.containsKey(name); return dataValues.containsKey(name);
} else { } else {
@@ -864,9 +876,6 @@ public class Frame {
private void createNestedElement(AntLibFactory factory, Setter setter, private void createNestedElement(AntLibFactory factory, Setter setter,
Object element, BuildElement model) Object element, BuildElement model)
throws ExecutionException { throws ExecutionException {
log("The use of create methods is deprecated - class: "
+ element.getClass().getName(), MessageLevel.MSG_INFO);

String nestedElementName = model.getType(); String nestedElementName = model.getType();
try { try {
Object nestedElement Object nestedElement


+ 8
- 6
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Factory.java View File

@@ -55,8 +55,8 @@ package org.apache.tools.ant;
import org.apache.ant.common.antlib.AntContext; import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.Converter; import org.apache.ant.common.antlib.Converter;
import org.apache.ant.common.antlib.StandardLibFactory; 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.service.EventService;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.init.LoaderUtils; import org.apache.ant.init.LoaderUtils;


/** /**
@@ -85,7 +85,7 @@ public class Ant1Factory extends StandardLibFactory {
if (project != null) { if (project != null) {
return; return;
} }
this.context = context; this.context = context;
// set the system classpath. In Ant2, the system classpath will not // set the system classpath. In Ant2, the system classpath will not
// in general, have any useful information. For Ant1 compatability // in general, have any useful information. For Ant1 compatability
@@ -94,8 +94,8 @@ public class Ant1Factory extends StandardLibFactory {


project = new Project(this); project = new Project(this);
project.init(context); project.init(context);
EventService eventService =
EventService eventService =
(EventService)context.getCoreService(EventService.class); (EventService)context.getCoreService(EventService.class);
eventService.addBuildListener(project); eventService.addBuildListener(project);
} }
@@ -105,12 +105,13 @@ public class Ant1Factory extends StandardLibFactory {
* Create an instance of the requested type class * Create an instance of the requested type class
* *
* @param typeClass the class from which an instance is required * @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 * @return an instance of the requested class
* @exception ExecutionException the instance could not be created. * @exception ExecutionException the instance could not be created.
* @exception InstantiationException if the type cannot be instantiated * @exception InstantiationException if the type cannot be instantiated
* @exception IllegalAccessException if the type cannot be accessed * @exception IllegalAccessException if the type cannot be accessed
*/ */
public Object createTypeInstance(Class typeClass)
public Object createTypeInstance(Class typeClass, String localName)
throws InstantiationException, IllegalAccessException, throws InstantiationException, IllegalAccessException,
ExecutionException { ExecutionException {
try { try {
@@ -145,11 +146,12 @@ public class Ant1Factory extends StandardLibFactory {
* Create an instance of the requested task class * Create an instance of the requested task class
* *
* @param taskClass the class from which an instance is required * @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 * @return an instance of the requested class
* @exception InstantiationException if the task cannot be instantiated * @exception InstantiationException if the task cannot be instantiated
* @exception IllegalAccessException if the task cannot be accessed * @exception IllegalAccessException if the task cannot be accessed
*/ */
public Object createTaskInstance(Class taskClass)
public Object createTaskInstance(Class taskClass, String localName)
throws InstantiationException, IllegalAccessException { throws InstantiationException, IllegalAccessException {
Object instance = taskClass.newInstance(); Object instance = taskClass.newInstance();
if (instance instanceof ProjectComponent) { if (instance instanceof ProjectComponent) {


+ 1
- 22
proposal/mutant/src/java/cli/org/apache/ant/cli/Commandline.java View File

@@ -72,9 +72,7 @@ import org.apache.ant.antcore.xml.ParseContext;
import org.apache.ant.antcore.xml.XMLParseException; import org.apache.ant.antcore.xml.XMLParseException;
import org.apache.ant.common.event.BuildListener; import org.apache.ant.common.event.BuildListener;
import org.apache.ant.common.model.Project; 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.ConfigException;
import org.apache.ant.common.util.Location;
import org.apache.ant.common.event.MessageLevel; import org.apache.ant.common.event.MessageLevel;
import org.apache.ant.init.InitConfig; import org.apache.ant.init.InitConfig;
import org.apache.ant.init.InitUtils; import org.apache.ant.init.InitUtils;
@@ -297,27 +295,8 @@ public class Commandline {
addBuildListeners(executionManager); addBuildListeners(executionManager);
executionManager.init(); executionManager.init();
executionManager.runBuild(project, targets, definedProperties); executionManager.runBuild(project, targets, definedProperties);
System.exit(0);
} catch (Throwable t) { } 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); System.exit(1);
} }
} }


Loading…
Cancel
Save