1 19 20 package org.netbeans.nbbuild; 21 22 import java.io.File ; 23 import java.util.ArrayList ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 import java.util.Set ; 27 import java.util.StringTokenizer ; 28 import java.util.TreeSet ; 29 import org.apache.tools.ant.BuildException; 30 import org.apache.tools.ant.Task; 31 import org.apache.tools.ant.types.FileSet; 32 33 40 public class PrintCvsModules extends Task { 41 42 private List <String > modules; private String selectorId; 44 private File dir; 45 private String cvsModulesProperty; 46 47 48 public void setModules (String s) { 49 StringTokenizer tok = new StringTokenizer (s, ", "); 50 modules = new ArrayList <String >(); 51 while (tok.hasMoreTokens ()) 52 modules.add(tok.nextToken ()); 53 } 54 55 58 public void setCvsModulesProperty(String p) { 59 cvsModulesProperty = p; 60 } 61 62 64 public void setId (String s) { 65 selectorId = s; 66 } 67 68 69 public void setDir (File f) { 70 dir = f; 71 } 72 73 public void execute () throws BuildException { 74 Set <String > cvslist = new TreeSet <String >(); 75 cvslist.add("nbbuild"); 76 for (String module: modules) { 77 int slash = module.indexOf('/'); 78 if (slash > 0) { 79 module = module.substring(0, slash); 80 } 81 cvslist.add(module); 82 } 83 84 log("selectedmodules="+modules); 85 log("cvsmodules="+cvslist); 86 if (cvsModulesProperty != null) { 87 StringBuffer cvslistSpaces = new StringBuffer (); 88 Iterator cvsIt = cvslist.iterator(); 89 while (cvsIt.hasNext()) { 90 if (cvslistSpaces.length() > 0) { 91 cvslistSpaces.append(' '); 92 } 93 cvslistSpaces.append((String ) cvsIt.next()); 94 } 95 getProject().setNewProperty(cvsModulesProperty, cvslistSpaces.toString()); 96 } 97 98 if (selectorId != null) { 99 FileSet set = new CvsFileSet(); 100 set.setDir(dir); 101 Iterator it = cvslist.iterator(); 102 while (it.hasNext()) { 103 String modname = (String ) it.next(); 104 set.createInclude().setName(modname + "/**/*"); 105 set.createExclude().setName(modname + "/www/**/*"); 106 set.createExclude().setName(modname + "/test/**/*"); 107 } 108 set.createExclude().setName("*/*/test/**/*"); 109 getProject().addReference(selectorId, set); 110 } 111 } 112 113 } 114 | Popular Tags |