1 19 20 package org.netbeans.nbbuild; 21 22 import java.util.*; 23 24 import org.apache.tools.ant.BuildException; 25 import org.apache.tools.ant.Project; 26 import org.apache.tools.ant.Task; 27 28 34 @Deprecated 35 public class ConfigureModules extends Task { 36 37 private String property, config; 38 private List<Config> configs = new LinkedList<Config>(); 39 40 41 public class Config { 42 public String name, modules; 43 44 public void setName (String n) { 45 name = n; 46 } 48 49 public void setModules (String m) { 50 modules = m; 51 } 53 public String toString () { 54 return name; 55 } 56 67 } 68 77 78 79 public void setProperty (String p) { 80 property = p; 81 } 82 83 public void setSelectedconfig (String c) { 84 config = c; 85 } 86 87 public Config createConfig () { 88 Config c = new Config (); 89 configs.add (c); 90 return c; 91 } 92 93 public void execute () throws BuildException { 94 if (property == null || config == null) 95 throw new BuildException("Must set both the property and selectedconfig attributes", getLocation()); 96 Iterator it = configs.iterator (); 97 while (it.hasNext ()) { 98 Config c = (Config) it.next (); 99 if (config.equals (c.name)) { 100 String value = c.modules; 101 if (value == null) 102 throw new BuildException("Missing modules attribute for config " + config, getLocation()); 103 if (getProject().getProperty(property) == null) { 104 getProject().setProperty(property, value); 105 } else { 106 log ("Note: not overriding property " + property, Project.MSG_VERBOSE); 107 } 108 return; 109 } 110 } 111 throw new BuildException("Unrecognized module configuration: " + config + "; pick from: " + configs, getLocation()); 112 } 113 114 } 115 | Popular Tags |