diff --git a/src/etc/testcases/taskdefs/copy.xml b/src/etc/testcases/taskdefs/copy.xml index f797fe422..b6257aca2 100644 --- a/src/etc/testcases/taskdefs/copy.xml +++ b/src/etc/testcases/taskdefs/copy.xml @@ -121,7 +121,76 @@ a=b= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This is file 1 + This is file 2 + This is file 3 + This is file @nr@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -135,7 +204,7 @@ a=b= + - diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java index d6ed2c400..e78de26f5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -31,6 +31,10 @@ import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.FilterSet; import org.apache.tools.ant.types.FilterChain; import org.apache.tools.ant.types.FilterSetCollection; +import org.apache.tools.ant.types.Resource; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.ResourceCollection; +import org.apache.tools.ant.types.resources.Resources; import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.IdentityMapper; @@ -274,7 +278,42 @@ public class Copy extends Task { public void addFileset(FileSet set) { filesets.addElement(set); } - + + /* JHM: It would be the finest solution to use this method directly. + * But if I understood the IntrospectionHelper(final Class bean) + * right - especially line 258ff (the last "else if" statement), + * I must have a class with an no-arg constructor. But I only + * have an interface. :-( + * So I have to add the three methods ... But I can reuse this + * method :-) + * + */ + public void add(ResourceCollection res) { + //TODO: implement resources + } + /** + * Adds a path element as a nested ResourceCollection. + * @param path + */ + public void addPath(Path path) { + //add((ResourceCollection)path); + } + /** + * Adds a Resource element as a nested ResourceCollection. + * @param path + * / + public void add(Resource res) { + add((ResourceCollection)res); + } + /** + * Adds a resources element as a nested ResourceCollection. + * @param path + * / + public void add(Resources res) { + add((ResourceCollection)res); + } + */ + /** * Define the mapper to map source to destination files. * @return a mapper to be configured. diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index c0f9ee345..e48618843 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -82,7 +82,6 @@ nice=org.apache.tools.ant.taskdefs.Nice libraries=org.apache.tools.ant.taskdefs.repository.Libraries length=org.apache.tools.ant.taskdefs.Length clone=org.apache.tools.ant.taskdefs.Clone -copypath=org.apache.tools.ant.taskdefs.CopyPath diagnostics=org.apache.tools.ant.taskdefs.DiagnosticsTask # optional tasks @@ -220,3 +219,4 @@ deltree=org.apache.tools.ant.taskdefs.Deltree rename=org.apache.tools.ant.taskdefs.Rename WsdlToDotnet=org.apache.tools.ant.taskdefs.optional.dotnet.WsdlToDotnet style=org.apache.tools.ant.taskdefs.XSLTProcess +copypath=org.apache.tools.ant.taskdefs.CopyPath diff --git a/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java b/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java index d71374163..8be9c8d13 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java @@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.BuildFileTest; import org.apache.tools.ant.util.FileUtils; import java.io.File; +import java.io.FileReader; import java.io.IOException; /** @@ -146,4 +147,63 @@ public class CopyTest extends BuildFileTest { expectBuildException("testMissingDirBail", "not-there doesn't exist"); assertTrue(getBuildException().getMessage().endsWith(" not found.")); } + + public void _testFileResourcePlain() { + executeTarget("testFileResourcePlain"); + File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt"); + File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt"); + File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt"); + assertTrue(file1.exists()); + assertTrue(file2.exists()); + assertTrue(file3.exists()); + } + + public void _testFileResourceWithMapper() { + executeTarget("testFileResourceWithMapper"); + File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt.bak"); + File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt.bak"); + File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt.bak"); + assertTrue(file1.exists()); + assertTrue(file2.exists()); + assertTrue(file3.exists()); + } + + public void _testFileResourceWithFilter() { + executeTarget("testFileResourceWithFilter"); + File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/fileNR.txt"); + assertTrue(file1.exists()); + try { + String file1Content = FILE_UTILS.readFully(new FileReader(file1)); + assertEquals(file1Content, "This is file 42"); + } catch (IOException e) { + // no-op: not a real business error + } + } + + public void _testPathAsResource() { + executeTarget("testPathAsResource"); + File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt.bak"); + File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt.bak"); + File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt.bak"); + assertTrue(file1.exists()); + assertTrue(file2.exists()); + assertTrue(file3.exists()); + } + + public void _testResourcePlain() { + executeTarget("testResourcePlain"); + } + + public void _testResourcePlainWithMapper() { + executeTarget("testResourcePlainWithMapper"); + } + + public void _testResourcePlainWithFilter() { + executeTarget("testResourcePlainWithFilter"); + } + + public void _testOnlineResources() { + executeTarget("testOnlineResources"); + } + }