You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by co...@locus.apache.org on 2000/08/23 01:31:31 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Expand.java

conor       00/08/22 16:31:31

  Modified:    src/main/org/apache/tools/ant/taskdefs Expand.java
  Log:
  Make expand a matching task.
  
  Revision  Changes    Path
  1.10      +26 -7     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Expand.java
  
  Index: Expand.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Expand.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Expand.java	2000/07/24 13:23:28	1.9
  +++ Expand.java	2000/08/22 23:31:31	1.10
  @@ -63,9 +63,9 @@
    * @author costin@dnt.ro
    * @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.
  @@ -84,9 +84,28 @@
           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 @@
        *
        * @param d Path to the directory.
        */
  -    public void setDest(String d) {
  +    public void setDest(File d) {
   	this.dest=d;
       }
   
  @@ -155,7 +174,7 @@
        *
        * @param s Path to zip-file.
        */
  -    public void setSrc(String s) {
  +    public void setSrc(File s) {
   	this.source = s;
       }
   }