Browse Source

Mutant can now compile ant although it did require 3 minor changes to the

Ant build file.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271154 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
ce1af4647d
5 changed files with 118 additions and 35 deletions
  1. +66
    -32
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionFrame.java
  2. +9
    -3
      proposal/mutant/src/java/antlibs/ant1compat/antlib.xml
  3. +16
    -0
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Factory.java
  4. +13
    -0
      proposal/mutant/src/java/common/org/apache/ant/common/antlib/AntLibFactory.java
  5. +14
    -0
      proposal/mutant/src/java/common/org/apache/ant/common/antlib/StandardLibFactory.java

+ 66
- 32
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionFrame.java View File

@@ -240,14 +240,12 @@ public class ExecutionFrame {
*/
protected void setInitialProperties(Map properties)
throws ExecutionException {
if (properties == null) {
return;
}
for (Iterator i = properties.keySet().iterator(); i.hasNext(); ) {
String name = (String)i.next();
Object value = properties.get(name);
setDataValue(name, value, false);
if (properties != null) {
addProperties(properties);
}

// add in system properties
addProperties(System.getProperties());
}

/**
@@ -413,6 +411,21 @@ public class ExecutionFrame {
}
}

/**
* Add a collection of properties to this frame
*
* @param properties the collection of property values, indexed by their
* names
* @exception ExecutionException if the frame cannot be created.
*/
protected void addProperties(Map properties) throws ExecutionException {
for (Iterator i = properties.keySet().iterator(); i.hasNext(); ) {
String name = (String)i.next();
Object value = properties.get(name);
setDataValue(name, value, false);
}
}

/**
* Create a new frame for a given project
*
@@ -567,8 +580,11 @@ public class ExecutionFrame {
failureCause = e;
throw e;
} catch (RuntimeException e) {
failureCause = e;
throw e;
ExecutionException ee =
new ExecutionException(e.getClass().getName() + ": "
+ e.getMessage(), e, model.getLocation());
failureCause = ee;
throw ee;
} finally {
eventSupport.fireTaskFinished(model, failureCause);
}
@@ -597,8 +613,11 @@ public class ExecutionFrame {
failureCause = e;
throw e;
} catch (RuntimeException e) {
failureCause = e;
throw e;
ExecutionException ee =
new ExecutionException(e.getClass().getName() + ": "
+ e.getMessage(), e, target.getLocation());
failureCause = ee;
throw ee;
} finally {
eventSupport.fireTargetFinished(target, failureCause);
}
@@ -722,9 +741,12 @@ public class ExecutionFrame {
*
* @param element the object to be configured
* @param model the BuildElement describing the object in the build file
* @param factory Ant Library factory associated with the element being
* configured
* @exception ExecutionException if the element cannot be configured
*/
private void configureElement(Object element, BuildElement model)
private void configureElement(AntLibFactory factory, Object element,
BuildElement model)
throws ExecutionException {

Reflector reflector = getReflector(element.getClass());
@@ -770,9 +792,11 @@ public class ExecutionFrame {
container.addTask(nestedContext.getTask());
} else {
if (reflector.supportsNestedAdder(nestedElementName)) {
addNestedElement(reflector, element, nestedElementModel);
addNestedElement(factory, reflector, element,
nestedElementModel);
} else if (reflector.supportsNestedCreator(nestedElementName)) {
createNestedElement(reflector, element, nestedElementModel);
createNestedElement(factory, reflector, element,
nestedElementModel);
} else {
throw new ExecutionException(model.getType()
+ " does not support the \"" + nestedElementName
@@ -791,34 +815,41 @@ public class ExecutionFrame {
* @param element the container object for which a nested element is
* required.
* @param model the build model for the nestd element
* @param factory Ant Library factory associated with the element
* creating the nested element
* @exception ExecutionException if the nested element cannot be
* created.
*/
private void createNestedElement(Reflector reflector, Object element,
BuildElement model)
private void createNestedElement(AntLibFactory factory, Reflector reflector,
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();
Object nestedElement
= reflector.createElement(element, nestedElementName);
try {
Object nestedElement
= reflector.createElement(element, nestedElementName);
factory.registerCreatedElement(nestedElement);
if (nestedElement instanceof ExecutionComponent) {
System.out.println("element is an execution component");
ExecutionComponent component
= (ExecutionComponent)nestedElement;
ExecutionContext context
= new ExecutionContext(this);
context.setModelElement(model);
component.init(context);
configureElement(nestedElement, model);
configureElement(factory, nestedElement, model);
component.validateComponent();
} else {
configureElement(nestedElement, model);
configureElement(factory, nestedElement, model);
}
} catch (ExecutionException e) {
e.setLocation(model.getLocation(), false);
throw e;
} catch (RuntimeException e) {
throw new ExecutionException(e.getClass().getName() + ": "
+ e.getMessage(), e, model.getLocation());
}
}

@@ -830,10 +861,12 @@ public class ExecutionFrame {
* @param element the container element in which the nested element will
* be created
* @param model the model of the nested element
* @param factory Ant Library factory associated with the element to
* which the attribute is to be added.
* @exception ExecutionException if the nested element cannot be created
*/
private void addNestedElement(Reflector reflector, Object element,
BuildElement model)
private void addNestedElement(AntLibFactory factory, Reflector reflector,
Object element, BuildElement model)
throws ExecutionException {

String nestedElementName = model.getType();
@@ -880,7 +913,7 @@ public class ExecutionFrame {
model.getLocation());
}

typeInstance = createTypeInstance(nestedType, null, model);
typeInstance = createTypeInstance(nestedType, factory, model);
}

// is the typeInstance compatible with the type expected
@@ -944,7 +977,7 @@ public class ExecutionFrame {
ClassLoader currentLoader = setContextLoader(taskClassLoader);
TaskContext taskContext = new TaskContext(this);
taskContext.init(taskClassLoader, task, model);
configureElement(element, model);
configureElement(libFactory, element, model);
task.validateComponent();
setContextLoader(currentLoader);
return taskContext;
@@ -967,6 +1000,9 @@ public class ExecutionFrame {
} catch (ExecutionException e) {
e.setLocation(model.getLocation(), false);
throw e;
} catch (RuntimeException e) {
throw new ExecutionException(e.getClass().getName() + ": "
+ e.getMessage(), e, model.getLocation());
}
}

@@ -1031,12 +1067,7 @@ public class ExecutionFrame {
BuildElement model)
throws ExecutionException {
try {
Object typeInstance = null;
if (libFactory == null) {
typeInstance = typeClass.newInstance();
} else {
typeInstance = libFactory.createTypeInstance(typeClass);
}
Object typeInstance = libFactory.createTypeInstance(typeClass);

if (typeInstance instanceof ExecutionComponent) {
ExecutionComponent component = (ExecutionComponent)typeInstance;
@@ -1044,10 +1075,10 @@ public class ExecutionFrame {
= new ExecutionContext(this);
context.setModelElement(model);
component.init(context);
configureElement(typeInstance, model);
configureElement(libFactory, typeInstance, model);
component.validateComponent();
} else {
configureElement(typeInstance, model);
configureElement(libFactory, typeInstance, model);
}
return typeInstance;
} catch (InstantiationException e) {
@@ -1061,6 +1092,9 @@ public class ExecutionFrame {
} catch (ExecutionException e) {
e.setLocation(model.getLocation(), false);
throw e;
} catch (RuntimeException e) {
throw new ExecutionException(e.getClass().getName() + ": "
+ e.getMessage(), e, model.getLocation());
}
}
}


+ 9
- 3
proposal/mutant/src/java/antlibs/ant1compat/antlib.xml View File

@@ -145,8 +145,14 @@
<taskdef name="xmlvalidate" classname="org.apache.tools.ant.taskdefs.optional.XMLValidateTask"/>
<taskdef name="zip" classname="org.apache.tools.ant.taskdefs.Zip"/>

<typedef name="patternset" classname="org.apache.tools.ant.types.PatternSet"/>
<typedef name="fileset" classname="org.apache.tools.ant.types.FileSet"/>
<typedef name="path" classname="org.apache.tools.ant.types.Path"/>

<typedef name="fileset" classname="org.apache.tools.ant.types.FileSet"/>
<typedef name="filelist" classname="org.apache.tools.ant.types.FileList"/>
<typedef name="patternset" classname="org.apache.tools.ant.types.PatternSet"/>
<typedef name="mapper" classname="org.apache.tools.ant.types.Mapper"/>
<typedef name="filterset" classname="org.apache.tools.ant.types.FilterSet"/>
<typedef name="description" classname="org.apache.tools.ant.types.Description"/>
<typedef name="classfileset" classname="org.apache.tools.ant.types.optional.depend.ClassfileSet"/>
<typedef name="substitution" classname="org.apache.tools.ant.types.Substitution"/>
<typedef name="regularexpression" classname="org.apache.tools.ant.types.RegularExpression"/>
</antlib>

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

@@ -185,5 +185,21 @@ public class Ant1Factory extends StandardLibFactory {
+ "constructor for converter " + converterClass.getName(), e);
}
}

/**
* Register an element which has been created as the result of calling a
* create method.
*
* @param createdElement the element that the component created
* @exception ExecutionException if there is a problem registering the
* element
*/
public void registerCreatedElement(Object createdElement)
throws ExecutionException {
if (createdElement instanceof ProjectComponent) {
ProjectComponent component = (ProjectComponent)createdElement;
component.setProject(project);
}
}
}


+ 13
- 0
proposal/mutant/src/java/common/org/apache/ant/common/antlib/AntLibFactory.java View File

@@ -112,5 +112,18 @@ public interface AntLibFactory {
Converter createConverter(Class converterClass)
throws InstantiationException, IllegalAccessException,
ExecutionException;


/**
* Register an element which has been created as the result of calling a
* create method.
*
* @param createdElement the element that the component created
* @exception ExecutionException if there is a problem registering the
* element
*/
void registerCreatedElement(Object createdElement)
throws ExecutionException;

}


+ 14
- 0
proposal/mutant/src/java/common/org/apache/ant/common/antlib/StandardLibFactory.java View File

@@ -118,5 +118,19 @@ public class StandardLibFactory implements AntLibFactory {
ExecutionException {
return (Converter)converterClass.newInstance();
}

/**
* Register an element which has been created as the result of calling a
* create method.
*
* @param createdElement the element that the component created
* @exception ExecutionException if there is a problem registering the
* element
*/
public void registerCreatedElement(Object createdElement)
throws ExecutionException {
// do nothing
}

}


Loading…
Cancel
Save