peterreilly 2004/01/13 02:39:54
Modified: src/main/org/apache/tools/ant IntrospectionHelper.java
src/etc/testcases/taskdefs presetdef.xml
src/testcases/org/apache/tools/ant/taskdefs
PreSetDefTest.java
Log:
Allow presetdef'ed types to be used with the ant-type attribute
Revision Changes Path
1.74 +11 -4
ant/src/main/org/apache/tools/ant/IntrospectionHelper.java
Index: IntrospectionHelper.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/IntrospectionHelper.java,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- IntrospectionHelper.java 7 Jan 2004 07:26:48 -0000 1.73
+++ IntrospectionHelper.java 13 Jan 2004 10:39:54 -0000 1.74
@@ -349,19 +349,22 @@
throws InvocationTargetException,
IllegalAccessException,
InstantiationException {
if (child != null) {
- return child;
} else if (c.getParameterTypes().length ==
0) {
- return c.newInstance(new Object[] {});
+ child = c.newInstance(new Object[] {});
} else {
- return c.newInstance(new Object[] {
+ child = c.newInstance(new Object[] {
project});
}
+ if (child instanceof
PreSetDef.PreSetDefinition) {
+ child = ((PreSetDef.PreSetDefinition)
child)
+ .createObject(project);
+ }
+ return child;
}
public void store(Object parent, Object child)
throws InvocationTargetException,
IllegalAccessException,
InstantiationException {
-
m.invoke(parent, new Object[] {child});
}
@@ -414,6 +417,10 @@
} else {
child = c.newInstance(new Object[] {
project});
+ }
+ if (child instanceof
PreSetDef.PreSetDefinition) {
+ child = ((PreSetDef.PreSetDefinition)
child)
+ .createObject(project);
}
m.invoke(parent, new Object[] {child});
return child;
1.3 +16 -0 ant/src/etc/testcases/taskdefs/presetdef.xml
Index: presetdef.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/presetdef.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- presetdef.xml 6 Nov 2003 09:04:08 -0000 1.2
+++ presetdef.xml 13 Jan 2004 10:39:54 -0000 1.3
@@ -49,6 +49,22 @@
<dd attribute="true"/>
</target>
+ <target name="antTypeTest">
+ <taskdef name="anttypetest"
+
classname="org.apache.tools.ant.taskdefs.PreSetDefTest$AntTypeTest"
+ classpathref="test-classes"/>
+ <presetdef name="java.fileset">
+ <fileset>
+ <include name="**/*.java"/>
+ </fileset>
+ </presetdef>
+
+ <anttypetest>
+ <fileset ant-type="java.fileset" dir="."/>
+ <configured ant-type="java.fileset" dir="."/>
+ </anttypetest>
+ </target>
+
<target name="text.optional">
<presetdef name="echo.mytext">
<echo>MyText</echo>
1.3 +16 -1
ant/src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java
Index: PreSetDefTest.java
===================================================================
RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PreSetDefTest.java 6 Nov 2003 09:04:08 -0000 1.2
+++ PreSetDefTest.java 13 Jan 2004 10:39:54 -0000 1.3
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,6 +58,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
/**
* @author Peter Reilly
@@ -102,6 +103,10 @@
public void testElementOrder2() {
expectLog("element.order2", "Line 1Line 2Line 3");
}
+
+ public void testAntTypeTest() {
+ expectLog("antTypeTest", "");
+ }
/**
* A test class to check default properties
@@ -119,6 +124,16 @@
public void execute() {
getProject().log("attribute is " + attribute);
+ }
+ }
+
+ /**
+ * A test class to check presetdef with add and addConfigured and
ant-type
+ */
+ public static class AntTypeTest extends Task {
+ public void addFileSet(FileSet fileset) {
+ }
+ public void addConfiguredConfigured(FileSet fileset) {
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]