1 37 package net.sourceforge.cruisecontrol.builders; 38 39 import java.util.Iterator ; 40 import java.util.List ; 41 import java.util.Map ; 42 import java.util.StringTokenizer ; 43 44 import net.sourceforge.cruisecontrol.util.Commandline; 45 46 52 public class NantScript implements Script { 53 private Map buildProperties; 54 private List nantProperties; 55 56 private String loggerClassName; 57 private String tempFileName = "log.xml"; 58 private boolean useLogger; 59 private boolean useQuiet; 60 private boolean useDebug; 61 private String buildFile = "default.build"; 62 private String target = ""; 63 private String targetFramework; 64 private int exitCode; 65 66 71 public Commandline buildCommandline() { 72 Commandline cmdLine = getCommandLine(); 73 74 cmdLine.setExecutable("NAnt.exe"); 75 if (useLogger) { 76 cmdLine.createArgument().setValue("-logger:" + getLoggerClassName()); 77 cmdLine.createArgument().setValue("-logfile:" + tempFileName); 78 } else { 79 cmdLine.createArgument().setValue("-listener:" + getLoggerClassName()); 80 cmdLine.createArgument().setValue("-D:XmlLogger.file=" + tempFileName); 81 } 82 87 if (useDebug) { 88 cmdLine.createArgument().setValue("-debug+"); 89 } else if (useQuiet) { 90 cmdLine.createArgument().setValue("-quiet+"); 91 } 92 if (targetFramework != null) { 93 cmdLine.createArgument().setValue("-t:" + targetFramework); 94 } 95 96 for (Iterator propertiesIter = buildProperties.entrySet().iterator(); propertiesIter.hasNext();) { 97 Map.Entry property = (Map.Entry ) propertiesIter.next(); 98 String value = (String ) property.getValue(); 99 if (!"".equals(value)) { 100 cmdLine.createArgument().setValue("-D:" + property.getKey() + "=" + value); 101 } 102 } 103 for (Iterator nantPropertiesIterator = nantProperties.iterator(); nantPropertiesIterator.hasNext(); ) { 104 Property property = (Property) nantPropertiesIterator.next(); 105 cmdLine.createArgument().setValue("-D:" + property.getName() + "=" + property.getValue()); 106 } 107 108 cmdLine.createArgument().setValue("-buildfile:" + buildFile); 109 110 StringTokenizer targets = new StringTokenizer (target); 111 while (targets.hasMoreTokens()) { 112 cmdLine.createArgument().setValue(targets.nextToken()); 113 } 114 return cmdLine; 115 } 116 117 protected Commandline getCommandLine() { 119 return new Commandline(); 120 } 121 122 125 public void setBuildProperties(Map buildProperties) { 126 this.buildProperties = buildProperties; 127 } 128 129 public void setNantProperties(List properties) { 130 this.nantProperties = properties; 131 } 132 133 136 public String getLoggerClassName() { 137 return loggerClassName; 138 } 139 142 public void setLoggerClassName(String loggerClassName) { 143 this.loggerClassName = loggerClassName; 144 } 145 148 public void setBuildFile(String buildFile) { 149 this.buildFile = buildFile; 150 } 151 154 public void setTempFileName(String tempFileName) { 155 this.tempFileName = tempFileName; 156 } 157 160 public void setUseDebug(boolean useDebug) { 161 this.useDebug = useDebug; 162 } 163 166 171 174 public void setUseLogger(boolean useLogger) { 175 this.useLogger = useLogger; 176 } 177 180 public void setUseQuiet(boolean useQuiet) { 181 this.useQuiet = useQuiet; 182 } 183 186 public void setTarget(String target) { 187 this.target = target; 188 } 189 192 public void setTargetFramework(String targetFramework) { 193 this.targetFramework = targetFramework; 194 } 195 198 public int getExitCode() { 199 return exitCode; 200 } 201 204 public void setExitCode(int exitCode) { 205 this.exitCode = exitCode; 206 } 207 } 208 | Popular Tags |