diff --git a/proposal/myrmidon/ant1compat.xml b/proposal/myrmidon/ant1compat.xml
index 3d625bfb4..ef3ecf415 100644
--- a/proposal/myrmidon/ant1compat.xml
+++ b/proposal/myrmidon/ant1compat.xml
@@ -5,11 +5,11 @@
-
+
-
+
@@ -20,7 +20,7 @@
-
+
@@ -83,8 +83,6 @@
-
-
diff --git a/proposal/myrmidon/build.xml b/proposal/myrmidon/build.xml
index 8c3709097..40f698156 100644
--- a/proposal/myrmidon/build.xml
+++ b/proposal/myrmidon/build.xml
@@ -188,10 +188,10 @@ Legal:
-
-
-
-
+
+
+
+
@@ -200,13 +200,13 @@ Legal:
-
+
-
+
@@ -527,6 +527,9 @@ Legal:
+
+
+
@@ -619,6 +622,12 @@ Legal:
+
+
+
+
+
+
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 07b01776a..511c78cce 100644
--- a/proposal/myrmidon/src/ant1compat/org/apache/tools/ant/Ant1CompatProject.java
+++ b/proposal/myrmidon/src/ant1compat/org/apache/tools/ant/Ant1CompatProject.java
@@ -22,10 +22,7 @@ import org.apache.aut.converter.Converter;
import org.apache.aut.converter.ConverterException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.interfaces.property.PropertyResolver;
import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
-import org.apache.myrmidon.interfaces.type.TypeException;
-import org.apache.myrmidon.interfaces.type.TypeFactory;
import org.apache.myrmidon.interfaces.type.TypeManager;
/**
@@ -49,12 +46,10 @@ public class Ant1CompatProject extends Project
URL ant1jar =
Ant1CompatProject.class.getProtectionDomain().getCodeSource().getLocation();
String ant1classpath = ant1jar.getFile().toString();
- javaclasspath = System.getProperty( "java.class.path" ) +
- File.pathSeparator +
- ant1classpath;
+ javaclasspath = System.getProperty( "java.class.path" );
+ javaclasspath = javaclasspath + File.pathSeparator + ant1classpath;
}
- private final PropertyResolver m_ant1PropertyResolver;
private final Converter m_converter;
private Set m_userProperties = new HashSet();
@@ -80,17 +75,6 @@ public class Ant1CompatProject extends Project
}
m_converter = (Converter)m_context.getService( Converter.class );
-
- TypeManager typeManager = (TypeManager)m_context.getService( TypeManager.class );
- try
- {
- TypeFactory factory = typeManager.getFactory( PropertyResolver.ROLE );
- m_ant1PropertyResolver = (PropertyResolver)factory.create( "classic" );
- }
- catch( TypeException e )
- {
- throw new TaskException( "Failed to create PropertyResolver.", e );
- }
}
/**
@@ -519,15 +503,8 @@ public class Ant1CompatProject extends Project
public String replaceProperties( String value )
throws BuildException
{
- try
- {
- return (String)m_ant1PropertyResolver.resolveProperties( value,
- m_context );
- }
- catch( TaskException e )
- {
- throw new BuildException( "Error resolving value: '" + value + "'", e );
- }
+ return ProjectHelper.replaceProperties( this, value,
+ this.getProperties() );
}
/**
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java b/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
index 6322ef6c3..b3467c387 100644
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
+++ b/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
@@ -13,6 +13,7 @@ import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.AbstractContainerTask;
+import org.apache.myrmidon.framework.conditions.AndCondition;
import org.apache.myrmidon.framework.conditions.Condition;
import org.apache.myrmidon.framework.conditions.IsTrueCondition;
import org.apache.myrmidon.framework.conditions.NotCondition;
@@ -60,6 +61,19 @@ public class IfTask
m_condition = new NotCondition( new IsTrueCondition( condition ) );
}
+ /**
+ * Add a nested "condition" element, which provides an AndCondition
+ * container for any type of condition.
+ * @param andCondition The configured Condition
+ * @throws TaskException If a condition has already been set.
+ */
+ public void addCondition( final AndCondition andCondition )
+ throws TaskException
+ {
+ verifyConditionNull();
+ m_condition = andCondition;
+ }
+
public void add( final Configuration task )
{
m_tasks.add( task );
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties b/proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties
index 757580ed6..2f0c47a3c 100644
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties
+++ b/proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties
@@ -19,7 +19,7 @@ enum.missing.getByName.error=Enum class "{0}" is missing a public static method
enum.missing.getNames.error=Enum class "{0}" is missing a public static method named "getNames" that returns a String array of all enum names.
invalid.enum.error=Invalid value "{0}" for enum, expected one of {1}.
-if.ifelse-duplicate.error=Can only set one of if/else for If task type.
+if.ifelse-duplicate.error=Can only set one condition for If task type. Conditions may be 'test' or 'not-test' attributes, or nested 'condition' elements.
if.no-condition.error=No condition was specified for If task.
trycatch.multiple-trys.error=Multiple elements can not be placed inside task.
diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ant1convert.xsl b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ant1convert.xsl
index e6aba539f..28980c7de 100644
--- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ant1convert.xsl
+++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ant1convert.xsl
@@ -1,114 +1,150 @@
-
-
-
- Converted Project file.
-
- 2.0
-
-
-
-
-
-
-
-
- Copied Project file.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Converted Project file.
+
+ 2.0
+
+
+
+
+
+
+
+
+ Copied Project file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/proposal/myrmidon/src/test/org/apache/antlib/core/test/IfTestCase.java b/proposal/myrmidon/src/test/org/apache/antlib/core/test/IfTestCase.java
index 11b489033..ce07846df 100644
--- a/proposal/myrmidon/src/test/org/apache/antlib/core/test/IfTestCase.java
+++ b/proposal/myrmidon/src/test/org/apache/antlib/core/test/IfTestCase.java
@@ -42,7 +42,7 @@ public class IfTestCase
executeTarget( projectFile, "true-prop", listener );
// Test when property is set to a value other than 'true' or 'false'
- executeTargetExpectError( projectFile, "set-prop", new String[0] );
+ executeTargetExpectError( projectFile, "set-prop", new String[ 0 ] );
// Test when property is set to 'false'
listener = new LogMessageTracker();
@@ -55,6 +55,24 @@ public class IfTestCase
executeTarget( projectFile, "not-set-prop", listener );
}
+ /**
+ * Test nested elements.
+ */
+ public void testNestedConditions()
+ throws Exception
+ {
+ final File projectFile = getTestResource( "if.ant" );
+
+ // Test when property is set to 'true'
+ LogMessageTracker listener = new LogMessageTracker();
+ listener.addExpectedMessage( "nested-conditions", "prop-true is set" );
+ listener.addExpectedMessage( "nested-conditions", "prop-false is set" );
+ listener.addExpectedMessage( "nested-conditions", "prop-true is true" );
+ listener.addExpectedMessage( "nested-conditions",
+ "prop-true is true and prop-false is not true" );
+ executeTarget( projectFile, "nested-conditions", listener );
+ }
+
/**
* Tests that the task can handle multiple nested tasks.
*/
@@ -92,7 +110,15 @@ public class IfTestCase
null,
REZ.getString( "if.ifelse-duplicate.error" )
};
+ // 2 condition attributes.
executeTargetExpectError( projectFile, "too-many-conditions", messages );
+
+ // attribute condition + nested condition
+ executeTargetExpectError( projectFile, "attribute-plus-nested-condition",
+ messages );
+
+ // 2 nested conditions
+ executeTargetExpectError( projectFile, "2-nested-conditions", messages );
}
}
diff --git a/proposal/myrmidon/src/test/org/apache/antlib/core/test/if.ant b/proposal/myrmidon/src/test/org/apache/antlib/core/test/if.ant
index b3caca2af..3dd4c3e08 100644
--- a/proposal/myrmidon/src/test/org/apache/antlib/core/test/if.ant
+++ b/proposal/myrmidon/src/test/org/apache/antlib/core/test/if.ant
@@ -38,6 +38,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -60,4 +111,27 @@
+
+
+
+
+
+
+ Double trouble.
+
+
+
+
+
+
+
+
+
+
+
+
+ 2 conditions not permitted.
+
+
+
\ No newline at end of file
diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/Ant1CompatTestCase.java b/proposal/myrmidon/src/test/org/apache/tools/ant/test/Ant1CompatTestCase.java
new file mode 100644
index 000000000..b7babd6c7
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/tools/ant/test/Ant1CompatTestCase.java
@@ -0,0 +1,103 @@
+/*
+ * 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.tools.ant.test;
+
+import java.io.File;
+import org.apache.myrmidon.AbstractProjectTest;
+import org.apache.myrmidon.LogMessageTracker;
+
+/**
+ * Simple tests for the Ant1 Compatibility layer.
+ *
+ * @author Darrell DeBoer
+ * @version $Revision$ $Date$
+ */
+public class Ant1CompatTestCase
+ extends AbstractProjectTest
+{
+ public Ant1CompatTestCase( final String name )
+ {
+ super( name );
+ }
+
+ public void testBasic() throws Exception
+ {
+ final File projectFile = getTestResource( "basic-test.xml" );
+
+ // test
+ LogMessageTracker tracker = new LogMessageTracker();
+ tracker.addExpectedMessage( "echo-test", "Hello, hello, hello" );
+ executeTarget( projectFile, "echo-test", tracker );
+
+ // Property resolution tests
+ tracker = new LogMessageTracker();
+ tracker.addExpectedMessage( "property-test", "prop-1 = [value-1]" );
+ tracker.addExpectedMessage( "property-test", "prop-2 = [value-2]" );
+ tracker.addExpectedMessage( "property-test", "prop-undefined = [${prop-undefined}]" );
+ tracker.addExpectedMessage( "property-test", "Omit, replace$, but keep ${} and $" );
+ executeTarget( projectFile, "property-test", tracker );
+ }
+
+ public void testIfUnless() throws Exception
+ {
+ final File projectFile = getTestResource( "if-unless-test.xml" );
+
+ // if/unless tests.
+ LogMessageTracker tracker = new LogMessageTracker();
+ // Should pass if for "set", "true" and "false"
+ tracker.addExpectedMessage( "if-set-test", "Ran target: if-set-test" );
+ tracker.addExpectedMessage( "if-true-test", "Ran target: if-true-test" );
+ tracker.addExpectedMessage( "if-false-test", "Ran target: if-false-test" );
+
+ // Should only pass unless, when not defined.
+ tracker.addExpectedMessage( "unless-unset-test",
+ "Ran target: unless-unset-test" );
+
+ // If combined with unless on a single target.
+ tracker.addExpectedMessage( "if-with-unless-test-1",
+ "Ran target: if-with-unless-test-1" );
+
+ executeTarget( projectFile, "if-unless-tests", tracker );
+ }
+
+ public void testAntTask() throws Exception
+ {
+ final File projectFile = getTestResource( "ant-task-test.xml" );
+
+ // TODO - Get the project listeners working, so we can test log messages.
+
+ LogMessageTracker tracker = new LogMessageTracker();
+ tracker.addExpectedMessage( "default-target", "In default target." );
+ tracker.addExpectedMessage( "echo-test", "Hello, hello, hello" );
+ // executeTarget( projectFile, "ant-samefile-test", tracker );
+ executeTarget( projectFile, "ant-samefile-test" );
+
+ tracker = new LogMessageTracker();
+ tracker.addExpectedMessage( "main",
+ "Executed subdir/build.xml (default target)" );
+ tracker.addExpectedMessage( "main",
+ "Executed subdir/build.xml (default target)" );
+ tracker.addExpectedMessage( "main",
+ "Executed subdir/build.xml (default target)" );
+ tracker.addExpectedMessage( "echo",
+ "Executed subdir/build.xml (echo target)" );
+ // executeTarget( projectFile, "ant-otherfile-test", tracker );
+ executeTarget( projectFile, "ant-otherfile-test" );
+
+ tracker = new LogMessageTracker();
+ tracker.addExpectedMessage( "property-test",
+ "test-prop = [test-value]" );
+ tracker.addExpectedMessage( "property-test",
+ "test-prop = [set in calling task]" );
+ tracker.addExpectedMessage( "property-test",
+ "test-prop = [set in calling target]" );
+ // executeTarget( projectFile, "ant-setprops-test", tracker );
+ executeTarget( projectFile, "ant-setprops-test" );
+ }
+
+}
diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/ant-task-test.xml b/proposal/myrmidon/src/test/org/apache/tools/ant/test/ant-task-test.xml
new file mode 100644
index 000000000..0e09c3b33
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/tools/ant/test/ant-task-test.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/basic-test.xml b/proposal/myrmidon/src/test/org/apache/tools/ant/test/basic-test.xml
new file mode 100644
index 000000000..93e2f0b18
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/tools/ant/test/basic-test.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/if-unless-test.xml b/proposal/myrmidon/src/test/org/apache/tools/ant/test/if-unless-test.xml
new file mode 100644
index 000000000..0838632ea
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/tools/ant/test/if-unless-test.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/subdir/build.xml b/proposal/myrmidon/src/test/org/apache/tools/ant/test/subdir/build.xml
new file mode 100644
index 000000000..317aee134
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/tools/ant/test/subdir/build.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file