adammurdoch 2002/07/01 19:50:55
Modified: antlib/src/java/org/apache/antlib/project
AbstractAntTask.java AntCallTask.java
antlib/src/test/org/apache/antlib/project/test
AntCallTaskTestCase.java AntTaskTestCase.java
ant-call.ant ant.ant
Log:
Replaced 'target' attribute of <ant> and <ant-call> tasks with 'targets'
attribute, which allows multiple target to be executed (all in the same
workspace). Added more unit tests.
Revision Changes Path
1.5 +12 -5
jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractAntTask.java
Index: AbstractAntTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractAntTask.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractAntTask.java 25 Jun 2002 14:45:55 -0000 1.4
+++ AbstractAntTask.java 2 Jul 2002 02:50:55 -0000 1.5
@@ -10,6 +10,7 @@
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.ExecuteTarget;
import org.apache.myrmidon.framework.project.AbstractWorkspaceTask;
+import java.util.StringTokenizer;
/**
* Abstract base class for Tasks which execute targets.
@@ -34,12 +35,18 @@
}
/**
- * set the target to process. If none is defined it will
- * execute the default target of the build file
+ * The targets to execute. If none is defined it will
+ * execute the default target of the build file.
*/
- public void setTarget( final String target )
+ public void setTargets( final String targetStr )
{
- m_exe.setTarget( target );
+ final StringTokenizer tokens = new StringTokenizer( targetStr, "," );
+ final String[] targets = new String[ tokens.countTokens() ];
+ for( int i = 0; i < targets.length; i++ )
+ {
+ targets[ i ] = tokens.nextToken().trim();
+ }
+ m_exe.setTargets( targets );
}
/**
1.10 +1 -6
jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AntCallTask.java
Index: AntCallTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AntCallTask.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AntCallTask.java 25 Jun 2002 14:45:55 -0000 1.9
+++ AntCallTask.java 2 Jul 2002 02:50:55 -0000 1.10
@@ -7,8 +7,6 @@
*/
package org.apache.antlib.project;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.ExecuteTarget;
import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
@@ -24,9 +22,6 @@
public class AntCallTask
extends AbstractAntTask
{
- private final static Resources REZ =
- ResourceManager.getPackageResources( AntCallTask.class );
-
private String m_projectName;
/**
1.2 +8 -1
jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/project/test/AntCallTaskTestCase.java
Index: AntCallTaskTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/project/test/AntCallTaskTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AntCallTaskTestCase.java 25 Jun 2002 11:23:29 -0000 1.1
+++ AntCallTaskTestCase.java 2 Jul 2002 02:50:55 -0000 1.2
@@ -29,9 +29,16 @@
final File projectFile = getTestResource( "ant-call.ant" );
executeTarget( projectFile, "default-target" );
executeTarget( projectFile, "call-target" );
+ executeTarget( projectFile, "call-targets" );
executeTarget( projectFile, "unknown-target" );
+ executeTarget( projectFile, "inherit-prop" );
+ executeTarget( projectFile, "set-prop" );
+ executeTarget( projectFile, "hide-prop" );
+ executeTarget( projectFile, "no-inherit-prop" );
+ executeTarget( projectFile, "datatype-prop" );
executeTarget( projectFile, "ref-default" );
executeTarget( projectFile, "ref-target" );
executeTarget( projectFile, "ref-unknown-target" );
+ executeTarget( projectFile, "ref-unknown-project" );
}
}
1.2 +2 -1
jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/project/test/AntTaskTestCase.java
Index: AntTaskTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/project/test/AntTaskTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AntTaskTestCase.java 27 Jun 2002 11:13:08 -0000 1.1
+++ AntTaskTestCase.java 2 Jul 2002 02:50:55 -0000 1.2
@@ -30,6 +30,7 @@
executeTarget( projectFile, "default-project" );
executeTarget( projectFile, "default-target" );
executeTarget( projectFile, "call-target" );
+ executeTarget( projectFile, "call-targets" );
executeTarget( projectFile, "unknown-target" );
executeTarget( projectFile, "unknown-file" );
}
1.4 +93 -5
jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/project/test/ant-call.ant
Index: ant-call.ant
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/project/test/ant-call.ant,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ant-call.ant 27 Jun 2002 11:13:08 -0000 1.3
+++ ant-call.ant 2 Jul 2002 02:50:55 -0000 1.4
@@ -2,6 +2,10 @@
<project version="2.0">
<projectref name="common" location="common-project.ant"/>
+ <!--
+ TARGETS IN SAME PROJECT
+ -->
+
<!-- Call default target -->
<target name="default-target">
<expect-output absolute-path="true">
@@ -29,7 +33,25 @@
</ant-call>
</out>
<tasks>
- <ant-call target="other-target"/>
+ <ant-call targets="other-target"/>
+ </tasks>
+ </expect-output>
+ </target>
+
+ <target name="call-targets">
+ <expect-output absolute-path="true">
+ <out>
+ <ant-call>
+ <main>
+ <log>In default target.</log>
+ </main>
+ <other-target>
+ <log>In other target.</log>
+ </other-target>
+ </ant-call>
+ </out>
+ <tasks>
+ <ant-call targets="main, other-target"/>
</tasks>
</expect-output>
</target>
@@ -40,11 +62,15 @@
<exc>Execution of target "no-such-target" in project
"${myrmidon.project/projectDescriptor/uri}" failed.</exc>
<exc>No target named "no-such-target" in project
"${myrmidon.project/projectDescriptor/uri}".</exc>
<tasks>
- <ant-call target="no-such-target"/>
+ <ant-call targets="no-such-target"/>
</tasks>
</expect-error>
</target>
+ <!--
+ PROJECT REFERENCES
+ -->
+
<!-- Call the default target in a referenced project -->
<target name="ref-default">
<expect-output absolute-path="true">
@@ -72,7 +98,7 @@
</common-project>
</out>
<tasks>
- <ant-call project="common" target="other-target"/>
+ <ant-call project="common" targets="other-target"/>
</tasks>
</expect-output>
</target>
@@ -83,13 +109,63 @@
<exc>Execution of target "no-such-target" in project
"${myrmidon.projectrefs/projectRefs/common/project/uri}" failed.</exc>
<exc>No target named "no-such-target" in project
"${myrmidon.projectrefs/projectRefs/common/project/uri}".</exc>
<tasks>
- <ant-call project="common" target="no-such-target"/>
+ <ant-call project="common" targets="no-such-target"/>
+ </tasks>
+ </expect-error>
+ </target>
+
+ <!-- Call a target in an unknown referenced project -->
+ <target name="ref-unknown-project">
+ <expect-error>
+ <exc>Unable to locate project "no-such-project".</exc>
+ <tasks>
+ <ant-call project="no-such-project"/>
</tasks>
</expect-error>
</target>
<!--
- Targets called by the tests
+ PROPERTY INHERITANCE
+ -->
+
+ <!-- Check property is inherited -->
+ <target name="inherit-prop">
+ <property name="inherited-prop" value="true"/>
+ <ant-call inherit-all="true" targets="check-prop"/>
+ </target>
+
+ <!-- Check property can be set -->
+ <target name="set-prop">
+ <ant-call targets="check-prop">
+ <param name="inherited-prop" value="true"/>
+ </ant-call>
+ </target>
+
+ <!-- Check property can be set to a data-type -->
+ <target name="datatype-prop">
+ <ant-call targets="check-datatype-prop">
+ <param name="path-prop">
+ <path location="."/>
+ </param>
+ </ant-call>
+ </target>
+
+ <!-- Check a property can be overridden -->
+ <target name="hide-prop">
+ <property name="inherited-prop" value="false"/>
+ <ant-call targets="check-prop">
+ <param name="inherited-prop" value="true"/>
+ </ant-call>
+ </target>
+
+ <!-- Check property is not inherited -->
+ <target name="no-inherit-prop">
+ <property name="inherited-prop" value="true"/>
+ <ant-call targets="check-no-prop"/>
+ </target>
+
+ <!--
+ TARGETS CALLED BY THE TESTS
-->
<target name="main">
@@ -98,6 +174,18 @@
<target name="other-target">
<log>In other target.</log>
+ </target>
+
+ <target name="check-prop">
+ <assert><is-true property="inherited-prop"/></assert>
+ </target>
+
+ <target name="check-datatype-prop">
+ <assert><is-instance property="path-prop" role="path"/></assert>
+ </target>
+
+ <target name="check-no-prop">
+ <assert><not><is-set property="inherited-prop"/></not></assert>
</target>
</project>
1.2 +20 -2
jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/project/test/ant.ant
Index: ant.ant
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/project/test/ant.ant,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ant.ant 27 Jun 2002 11:13:08 -0000 1.1
+++ ant.ant 2 Jul 2002 02:50:55 -0000 1.2
@@ -40,7 +40,25 @@
</common-project>
</out>
<tasks>
- <ant file="common-project.ant" target="other-target"/>
+ <ant file="common-project.ant" targets="other-target"/>
+ </tasks>
+ </expect-output>
+ </target>
+
+ <target name="call-targets">
+ <expect-output absolute-path="true">
+ <out>
+ <common-project>
+ <main>
+ <log>common: In default target.</log>
+ </main>
+ <other-target>
+ <log>common: In other target.</log>
+ </other-target>
+ </common-project>
+ </out>
+ <tasks>
+ <ant file="common-project.ant" targets="main, other-target"/>
</tasks>
</expect-output>
</target>
@@ -53,7 +71,7 @@
<exc>Execution of target "no-such-target" in project "${uri}"
failed.</exc>
<exc>No target named "no-such-target" in project "${uri}".</exc>
<tasks>
- <ant file="common-project.ant" target="no-such-target"/>
+ <ant file="common-project.ant" targets="no-such-target"/>
</tasks>
</expect-error>
</target>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>