Browse Source

Allow presetdef'ed types to be used with the ant-type attribute

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275903 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
4a56f455f2
3 changed files with 43 additions and 5 deletions
  1. +16
    -0
      src/etc/testcases/taskdefs/presetdef.xml
  2. +11
    -4
      src/main/org/apache/tools/ant/IntrospectionHelper.java
  3. +16
    -1
      src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java

+ 16
- 0
src/etc/testcases/taskdefs/presetdef.xml View File

@@ -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>


+ 11
- 4
src/main/org/apache/tools/ant/IntrospectionHelper.java View File

@@ -349,19 +349,22 @@ public final class IntrospectionHelper implements BuildListener {
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});
}

@@ -415,6 +418,10 @@ public final class IntrospectionHelper implements BuildListener {
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;
}


+ 16
- 1
src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java View File

@@ -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.BuildFileTest;
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 class PreSetDefTest extends BuildFileTest {
public void testElementOrder2() {
expectLog("element.order2", "Line 1Line 2Line 3");
}

public void testAntTypeTest() {
expectLog("antTypeTest", "");
}
/**
* A test class to check default properties
@@ -121,5 +126,15 @@ public class PreSetDefTest extends BuildFileTest {
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) {
}
}
}


Loading…
Cancel
Save