1 17 18 19 20 package org.apache.lenya.cms.ant; 21 22 import java.io.File ; 23 import java.io.FilenameFilter ; 24 import java.util.StringTokenizer ; 25 26 import org.apache.tools.ant.BuildException; 27 import org.apache.tools.ant.Task; 28 import org.apache.tools.ant.types.Path; 29 30 31 public class CopyTask extends Task { 32 private Path pubsRootDirs; 33 private Path toDir; 34 private String excludes; 35 36 39 public void execute() throws BuildException { 40 int numberOfDirectoriesCreated = 0; 41 int numberOfFilesCopied = 0; 42 TwoTuple twoTuple = new TwoTuple(numberOfDirectoriesCreated, numberOfFilesCopied); 43 44 StringTokenizer st = new StringTokenizer (pubsRootDirs.toString(), File.pathSeparator); 45 46 log("Excludes " + excludes); 47 FilenameFilter filter = new SCMFilenameFilter(excludes); 48 49 while (st.hasMoreTokens()) { 50 String pubsRootDir = st.nextToken(); 51 52 if (new File (pubsRootDir, "publication.xml").isFile()) { 53 CopyJavaSourcesTask.copyDir(new File (pubsRootDir), new File (toDir.toString()), 54 twoTuple, filter); 55 } else { 56 CopyJavaSourcesTask.copyContentOfDir(new File (pubsRootDir), 58 new File (toDir.toString()), twoTuple, filter); 59 } 60 } 61 62 numberOfDirectoriesCreated = twoTuple.x; 63 numberOfFilesCopied = twoTuple.y; 64 log("Copying " + numberOfDirectoriesCreated + " directories to " + toDir); 65 log("Copying " + numberOfFilesCopied + " files to " + toDir); 66 } 67 68 73 public void setPubsRootDirs(Path pubsRootDirs) { 74 this.pubsRootDirs = pubsRootDirs; 75 } 76 77 82 public void setToDir(Path toDir) { 83 this.toDir = toDir; 84 } 85 86 91 public void setExcludes(String excludes) { 92 this.excludes = excludes; 93 } 94 } 95 | Popular Tags |