1 19 20 package org.netbeans.nbbuild; 21 22 import org.apache.tools.ant.*; 23 import org.apache.tools.ant.types.*; 24 import java.util.StringTokenizer ; 25 import java.io.File ; 26 import java.util.Iterator ; 27 28 31 public class SetClusterPatternSet extends Task { 32 PatternSet pattern = null; 33 34 private String property = null; 35 private String clusterName = null; 36 private File trackingPath = null; 37 private String clusterDir = null; 38 39 public void setCluster( String cluster ){ 40 clusterName = cluster; 41 } 42 43 public void setName( String name ) { 44 property = name; 45 } 46 47 public void setTrackingPath( File path ) { 48 trackingPath = path; 49 } 50 51 public void setClusterDir( String dir ) { 52 clusterDir = dir; 53 } 54 55 public void execute() throws BuildException { 56 if (clusterName == null) { 57 throw new BuildException("Cluster property must be set", getLocation()); 58 } 59 if (property == null) { 60 throw new BuildException("Name of the patternset must be set.", getLocation()); 61 } 62 if (trackingPath == null) { 63 throw new BuildException("Path to module_tracking.xml file must be set.", getLocation()); 64 } 65 if (clusterDir == null) { 66 throw new BuildException("Cluster directory must be set.", getLocation()); 67 } 68 69 String clusterList = this.getProject().getProperty(clusterName); 70 if (clusterList == null) { 71 throw new BuildException("Cluster " + clusterName + " doesn't exist", getLocation()); 72 } 73 pattern = (PatternSet) this.getProject().createDataType("patternset"); 74 75 ModuleTracking tracking = new ModuleTracking(trackingPath.getAbsolutePath()); 76 StringTokenizer moduleTokens = new StringTokenizer (clusterList, " \t\n\f\r,"); 77 while (moduleTokens.hasMoreTokens()) { 78 String module = moduleTokens.nextToken(); 79 Iterator files = tracking.getFilesForModule(module); 80 if (files==null) { 81 log("This module doesn't have module tracking info: " + module, Project.MSG_INFO); 82 continue; 83 } 84 while (files.hasNext()) 85 pattern.createInclude().setName(clusterDir + File.separator + (String )files.next()); 86 } 87 88 if (pattern.getIncludePatterns(this.getProject()) == null) 89 pattern.createExclude().setName("**"); 90 91 this.getProject().addReference(property, pattern); 92 } 93 } 94 | Popular Tags |