1 19 20 package org.netbeans.modules.web.project.ant; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import org.apache.tools.ant.BuildException; 25 import org.apache.tools.ant.PathTokenizer; 26 import org.apache.tools.ant.Task; 27 28 import org.apache.tools.ant.Project; 29 import org.apache.tools.ant.taskdefs.Copy; 30 import org.apache.tools.ant.types.FileSet; 31 32 41 public class CopyFiles extends Task { 42 43 private File todir; 44 private String files; 45 46 public void execute() throws BuildException { 47 48 PathTokenizer tokenizer = new PathTokenizer (getFiles ()); 49 while (tokenizer.hasMoreTokens ()) { 50 File f = getProject().resolveFile(tokenizer.nextToken()); 51 Copy cp = (Copy) getProject ().createTask ("copy"); 52 cp.setTodir (getToDir ()); 53 if (f.isDirectory ()) { 54 FileSet fset = new FileSet (); 55 fset.setDir (f); 56 cp.addFileset (fset); 57 } else { 58 cp.setFile (f); 59 } 60 cp.execute (); 61 } 62 } 63 64 public String getFiles() { 65 return this.files; 66 } 67 68 public void setFiles (String files) { 69 this.files = files; 70 } 71 72 public File getToDir() { 73 return this.todir; 74 } 75 76 public void setToDir (File todir) { 77 this.todir = todir; 78 } 79 } 80 | Popular Tags |