Browse Source

Make expand a matching task.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267939 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 25 years ago
parent
commit
bb0594b899
1 changed files with 26 additions and 7 deletions
  1. +26
    -7
      src/main/org/apache/tools/ant/taskdefs/Expand.java

+ 26
- 7
src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -63,9 +63,9 @@ import java.util.zip.*;
* @author costin@dnt.ro * @author costin@dnt.ro
* @author <a href="mailto:stefan.bodewig@megabit.net">Stefan Bodewig</a> * @author <a href="mailto:stefan.bodewig@megabit.net">Stefan Bodewig</a>
*/ */
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. * Do the work.
@@ -84,9 +84,28 @@ public class Expand extends Task {
touch.setTaskName(getTaskName()); touch.setTaskName(getTaskName());
touch.setLocation(getLocation()); 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; ZipInputStream zis = null;
try { try {
@@ -146,7 +165,7 @@ public class Expand extends Task {
* *
* @param d Path to the directory. * @param d Path to the directory.
*/ */
public void setDest(String d) {
public void setDest(File d) {
this.dest=d; this.dest=d;
} }


@@ -155,7 +174,7 @@ public class Expand extends Task {
* *
* @param s Path to zip-file. * @param s Path to zip-file.
*/ */
public void setSrc(String s) {
public void setSrc(File s) {
this.source = s; this.source = s;
} }
} }

Loading…
Cancel
Save