From bb0594b899cd5b5f752bcaff0bb0c2387547a356 Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Tue, 22 Aug 2000 23:31:31 +0000 Subject: [PATCH] Make expand a matching task. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267939 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/Expand.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Expand.java b/src/main/org/apache/tools/ant/taskdefs/Expand.java index 707f1dec1..e637c8550 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Expand.java +++ b/src/main/org/apache/tools/ant/taskdefs/Expand.java @@ -63,9 +63,9 @@ import java.util.zip.*; * @author costin@dnt.ro * @author Stefan Bodewig */ -public class Expand extends Task { - private String dest; // req - private String source; // req +public class Expand extends MatchingTask { + private File dest; // req + private File source; // req /** * Do the work. @@ -84,9 +84,28 @@ public class Expand extends Task { touch.setTaskName(getTaskName()); touch.setLocation(getLocation()); - File srcF=project.resolveFile(source); - File dir=project.resolveFile(dest); + if (source == null) { + throw new BuildException("Source attribute must be specified"); + } + + if (source.isDirectory()) { + // get all the files in the descriptor directory + DirectoryScanner ds = super.getDirectoryScanner(source); + + String[] files = ds.getIncludedFiles(); + for (int i = 0; i < files.length; ++i) { + File file = new File(source, files[i]); + expandFile(touch, file, dest); + } + } + else { + expandFile(touch, source, dest); + } + + } + + private void expandFile(Touch touch, File srcF, File dir) { ZipInputStream zis = null; try { @@ -146,7 +165,7 @@ public class Expand extends Task { * * @param d Path to the directory. */ - public void setDest(String d) { + public void setDest(File d) { this.dest=d; } @@ -155,7 +174,7 @@ public class Expand extends Task { * * @param s Path to zip-file. */ - public void setSrc(String s) { + public void setSrc(File s) { this.source = s; } }