1 19 20 package org.netbeans.nbbuild; 21 22 import java.io.*; 23 import java.util.*; 24 25 import org.apache.tools.ant.BuildException; 26 import org.apache.tools.ant.taskdefs.*; 27 import org.apache.tools.ant.Task; 28 import org.apache.tools.ant.Project; 29 30 34 public class GetDependsClusters extends Task { 35 private String name = null; 36 private String propertiesList = null; 37 private String thisModuleName = null; 38 39 40 public void setList( String propertiesList ) { 41 this.propertiesList = propertiesList; 42 } 43 44 45 public void setName(String name) { 46 this.name = name; 47 } 48 49 public void execute() throws BuildException { 50 if (name == null) 51 throw new BuildException("Name of property to set have to be specified",this.getLocation()); 52 if (propertiesList == null) 53 throw new BuildException("List of clusters have to be specified",this.getLocation()); 54 55 thisModuleName = this.getOwningTarget().getName(); 56 if (!thisModuleName.startsWith("all-")) 57 throw new BuildException("This task could be used only in targets \"all-{modulename}\"",this.getLocation()); 58 thisModuleName = thisModuleName.substring("all-".length()); 59 60 StringTokenizer tokens = new StringTokenizer( propertiesList, " \t\n\f\r," ); 61 while (tokens.hasMoreTokens()) { 62 String property = tokens.nextToken().trim(); 63 String list = this.getProject().getProperty( property ); 64 if (list == null) throw new BuildException("Property: " + property + " is not defined anywhere",this.getLocation()); 65 StringTokenizer modTokens = new StringTokenizer(list," \t\n\f\r,"); 66 while (modTokens.hasMoreTokens()) { 67 String module = modTokens.nextToken(); 68 log( property + " " + module, Project.MSG_VERBOSE ); 69 if (module.equals(thisModuleName)) { 70 String clusterDepends = this.getProject().getProperty(property + ".depends"); 71 if (clusterDepends == null) throw new BuildException( "Property: " + property + ".depends have to be defined", this.getLocation()); 72 log( "Property: " + name + " will be set to " + clusterDepends, Project.MSG_VERBOSE); 73 this.getProject().setProperty( name, clusterDepends ); 74 return; 75 } 76 } 77 } 78 log("No cluster list with this module: " + thisModuleName + " was found. Assume that this module " + thisModuleName + " depends on all clusters: " + propertiesList, Project.MSG_WARN); 79 log( "Property: " + name + " will be set to " + propertiesList, Project.MSG_VERBOSE); 80 this.getProject().setProperty( name, propertiesList ); 81 } 83 } 84 | Popular Tags |