diff --git a/proposal/myrmidon/build.xml b/proposal/myrmidon/build.xml
index 1dd30f7a9..53d6664a7 100644
--- a/proposal/myrmidon/build.xml
+++ b/proposal/myrmidon/build.xml
@@ -48,6 +48,7 @@ Legal:
+
@@ -70,14 +71,15 @@ Legal:
-
-
+
+
+
@@ -199,7 +201,6 @@ Legal:
-
@@ -236,7 +237,10 @@ Legal:
+ deprecation="${deprecation}"
+ includeAntRuntime="false"
+ includeJavaRuntime="false">
+
@@ -255,16 +259,6 @@ Legal:
-
-
-
-
-
-
-
@@ -290,6 +284,7 @@ Legal:
+
@@ -551,7 +546,12 @@ Legal:
destdir="${test.classes}"
debug="${debug}"
deprecation="${deprecation}">
-
+
+
+
+
+
+
@@ -611,12 +611,12 @@ Legal:
tofile="${test.classes}/META-INF/ant-descriptor.xml"/>
-
+
-
-
+
@@ -767,6 +767,8 @@ Legal:
+
+
@@ -797,6 +799,8 @@ Legal:
+
+
diff --git a/proposal/myrmidon/lib/xalan.jar b/proposal/myrmidon/lib/xalan.jar
deleted file mode 100644
index 3681818e1..000000000
Binary files a/proposal/myrmidon/lib/xalan.jar and /dev/null differ
diff --git a/proposal/myrmidon/lib/xml-apis.jar b/proposal/myrmidon/lib/xml-apis.jar
deleted file mode 100644
index 8331d27f1..000000000
Binary files a/proposal/myrmidon/lib/xml-apis.jar and /dev/null differ
diff --git a/proposal/myrmidon/src/ant1compat/org/apache/tools/ant/Ant1CompatProject.java b/proposal/myrmidon/src/ant1compat/org/apache/tools/ant/Ant1CompatProject.java
index 2d8765787..03081a039 100644
--- a/proposal/myrmidon/src/ant1compat/org/apache/tools/ant/Ant1CompatProject.java
+++ b/proposal/myrmidon/src/ant1compat/org/apache/tools/ant/Ant1CompatProject.java
@@ -10,7 +10,6 @@ package org.apache.tools.ant;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.security.CodeSource;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
@@ -25,6 +24,8 @@ import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
import org.apache.myrmidon.interfaces.type.TypeManager;
+import org.apache.tools.ant.types.Path;
+
/**
* Ant1 Project proxy for Myrmidon. Provides hooks between Myrmidon TaskContext
* and Ant1 project.
@@ -42,19 +43,9 @@ public class Ant1CompatProject extends Project
org.apache.myrmidon.interfaces.model.Project.PROJECT;
public static final String ANT1_PROJECT_PROP = "ant1.project";
- private static String javaclasspath;
-
- static
- {
- // Find the path to the Ant1 antlib file.
- CodeSource ant1codesource =
- Ant1CompatProject.class.getProtectionDomain().getCodeSource();
- String ant1jar = ant1codesource.getLocation().getFile().toString();
-
- // Append this to the java.class.path system property.
- javaclasspath = System.getProperty( "java.class.path" );
- javaclasspath = javaclasspath + File.pathSeparator + ant1jar;
- }
+ // Add everything in the current classloader to the
+ // java.class.path property.
+ private static String javaclasspath = Path.systemClasspath.toString();
private final Converter m_converter;
diff --git a/proposal/myrmidon/src/ant1compat/org/apache/tools/ant/types/Path.java b/proposal/myrmidon/src/ant1compat/org/apache/tools/ant/types/Path.java
index a63aa0d3f..c8f0a8585 100644
--- a/proposal/myrmidon/src/ant1compat/org/apache/tools/ant/types/Path.java
+++ b/proposal/myrmidon/src/ant1compat/org/apache/tools/ant/types/Path.java
@@ -112,10 +112,11 @@ public class Path extends DataType implements Cloneable {
//Modified from original source.
- //Append Ant1 codebase to systemclasspath.
+ //Append Ant1Compat classpath to systemclasspath.
// ------------------Modified--------------------------------
static
{
+ // Add Ant1Compat.atl to system classpath.
String classpath = LoaderUtils.getClasspath( Path.class.getClassLoader() );
systemClasspath.append( new Path( null, classpath ) );
}
diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ConvertingProjectBuilder.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ConvertingProjectBuilder.java
new file mode 100644
index 000000000..676e9687d
--- /dev/null
+++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ConvertingProjectBuilder.java
@@ -0,0 +1,237 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.myrmidon.components.builder;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.myrmidon.interfaces.builder.ProjectException;
+
+/**
+ * A simple ProjectBuilder, which programmatically converts an Ant1 Project
+ * configuration into a Myrmidon one.
+ *
+ * @author Darrell DeBoer
+ * @version $Revision$ $Date$
+ *
+ * @ant.type type="project-builder" name="xml"
+ */
+public class ConvertingProjectBuilder
+ extends DefaultProjectBuilder
+{
+ private static final String VERSION_ATTRIBUTE = "version";
+
+ protected Configuration parseProject( String systemID )
+ throws ProjectException
+ {
+ Configuration originalConfig = super.parseProject( systemID );
+
+ // Check the version, if it's present, just use this config.
+ // TODO: check for version < 2.0
+ if( originalConfig.getAttribute( VERSION_ATTRIBUTE, null ) != null )
+ {
+ return originalConfig;
+ }
+
+ // Convert the config by prepending "ant1." on tasks,
+ // and using tasks instead of target 'if=' and 'unless='
+ DefaultConfiguration newConfig = copyConfiguration( originalConfig );
+
+ // Put a new version attribute.
+ newConfig.setAttribute( VERSION_ATTRIBUTE, "2.0" );
+
+ // Copy the remaining attributes.
+ Set omitAttributes = new HashSet();
+ omitAttributes.add( VERSION_ATTRIBUTE );
+ copyAttributes( originalConfig, newConfig, omitAttributes );
+
+ // Now copy/convert the children
+ Configuration[] children = originalConfig.getChildren();
+ for( int i = 0; i < children.length; i++ )
+ {
+ Configuration child = children[ i ];
+
+ if( child.getName().equals( "target" ) )
+ {
+ newConfig.addChild( convertTarget( child ) );
+ }
+ else
+ {
+ newConfig.addChild( convertTask( child ) );
+ }
+ }
+
+ return newConfig;
+ }
+
+ /**
+ * Converts Configuration for an Ant1 Target into a Myrmidon version.
+ * @param originalTarget The Ant1 Target
+ * @return the converted target
+ */
+ private Configuration convertTarget( Configuration originalTarget )
+ {
+ DefaultConfiguration newTarget = copyConfiguration( originalTarget );
+
+ // Copy all attributes except 'if' and 'unless'
+ Set omitAttributes = new HashSet();
+ omitAttributes.add( "if" );
+ omitAttributes.add( "unless" );
+ copyAttributes( originalTarget, newTarget, omitAttributes );
+
+ DefaultConfiguration containerElement = newTarget;
+
+ // For 'if="prop-name"', replace with task.
+ String ifAttrib = originalTarget.getAttribute( "if", null );
+ if ( ifAttrib != null )
+ {
+ DefaultConfiguration ifElement =
+ buildIfElement( ifAttrib, false, originalTarget.getLocation() );
+ containerElement.addChild( ifElement );
+ // Treat the ifElement as the enclosing target.
+ containerElement = ifElement;
+ }
+
+ // For 'unless="prop-name"', replace with task (negated).
+ String unlessAttrib = originalTarget.getAttribute( "unless", null );
+ if ( unlessAttrib != null )
+ {
+ DefaultConfiguration unlessElement =
+ buildIfElement( unlessAttrib, true, originalTarget.getLocation() );
+ containerElement.addChild( unlessElement );
+ // Treat the unlessElement as the enclosing target.
+ containerElement = unlessElement;
+ }
+
+ // Now copy in converted tasks.
+ Configuration[] tasks = originalTarget.getChildren();
+ for( int i = 0; i < tasks.length; i++ )
+ {
+ containerElement.addChild( convertTask( tasks[ i ] ) );
+ }
+
+ return newTarget;
+ }
+
+ /**
+ * Builds configuration for an task, to replace a "if" or "unless"
+ * attribute on a Ant1 target.
+ * @param ifProperty the name of the property from the Ant1 attribute.
+ * @param unless if the attribute is actually an "unless" attribute.
+ * @param location the configuration location to use
+ * @return The configuration for an task
+ */
+ private DefaultConfiguration buildIfElement( String ifProperty,
+ boolean unless,
+ final String location )
+ {
+ //
+ //
+ //
+ //
+ // .. tasks
+ //
+ DefaultConfiguration isSetElement =
+ new DefaultConfiguration( "is-set", location );
+ isSetElement.setAttribute( "property", ifProperty );
+
+ DefaultConfiguration conditionElement =
+ new DefaultConfiguration( "condition", location );
+
+ if ( unless )
+ {
+ // Surround with
+ DefaultConfiguration notElement =
+ new DefaultConfiguration( "not", location );
+ notElement.addChild( isSetElement );
+ conditionElement.addChild( notElement );
+ }
+ else
+ {
+ conditionElement.addChild( isSetElement );
+ }
+
+
+ DefaultConfiguration ifElement =
+ new DefaultConfiguration( "if", location );
+ ifElement.addChild( conditionElement );
+
+ return ifElement;
+ }
+
+ /**
+ * Converts Configuration for an Ant1 Task into a Myrmidon version.
+ * @param originalTask The Ant1 Task
+ * @return the converted task
+ */
+ private Configuration convertTask( Configuration originalTask )
+ {
+ // Create a new configuration with the "ant1." prefix.
+ String newTaskName = "ant1." + originalTask.getName();
+ DefaultConfiguration newTask =
+ new DefaultConfiguration( newTaskName, originalTask.getLocation() );
+
+ // Copy all attributes and elements of the task.
+ copyAttributes( originalTask, newTask, new HashSet() );
+ copyChildren( originalTask, newTask );
+
+ return newTask;
+ }
+
+ /**
+ * Copies all child elements from one configuration to another
+ * @param from Configuration to copy from
+ * @param to Configuration to copy to
+ */
+ private void copyChildren( Configuration from, DefaultConfiguration to )
+ {
+ Configuration[] children = from.getChildren();
+ for( int i = 0; i < children.length; i++ )
+ {
+ to.addChild( children[ i ] );
+ }
+ }
+
+ /**
+ * Copies all attributes from one configuration to another, excluding
+ * specified attribute names.
+ * @param from Configuration to copy from
+ * @param to Configuration to copy to
+ * @param omitAttributes a Set of attribute names to exclude
+ */
+ private void copyAttributes( Configuration from,
+ DefaultConfiguration to,
+ Set omitAttributes )
+ {
+ // Copy other attributes
+ String[] attribs = from.getAttributeNames();
+ for( int i = 0; i < attribs.length; i++ )
+ {
+ String name = attribs[ i ];
+ if( omitAttributes.contains( name ) )
+ {
+ continue;
+ }
+ String value = from.getAttribute( name, "" );
+ to.setAttribute( name, value );
+ }
+ }
+
+ /**
+ * Creates a DefaultConfiguration with the same name and location as
+ * the one supplied.
+ * @param originalConfig the COnfiguration to copy.
+ * @return the new Configuration
+ */
+ private DefaultConfiguration copyConfiguration( Configuration originalConfig )
+ {
+ return new DefaultConfiguration( originalConfig.getName(),
+ originalConfig.getLocation() );
+ }
+}
diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/TransformingProjectBuilder.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/TransformingProjectBuilder.java
index 58b8c9eb1..1a659075d 100644
--- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/TransformingProjectBuilder.java
+++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/TransformingProjectBuilder.java
@@ -27,7 +27,7 @@ import org.apache.myrmidon.interfaces.builder.ProjectException;
* @author Darrell DeBoer
* @version $Revision$ $Date$
*
- * @ant.type type="project-builder" name="xml"
+ * @ant.type type="project-builder" name="ant-transform"
*/
public class TransformingProjectBuilder
extends DefaultProjectBuilder