* construct the command that we're going to execute.
* @return Commandline holding command to be executed
* @throws CruiseControlException
*/
public Commandline buildCommandline() throws CruiseControlException {
Commandline cmdLine = new Commandline();
if (mavenScript != null) {
cmdLine.setExecutable(mavenScript);
} else {
throw new CruiseControlException(
"Non-script running is not implemented yet.\n"
+ "As of 1.0-beta-10 Maven startup mechanism is still changing...");
}
Iterator propertiesIterator = buildProperties.keySet().iterator();
while (propertiesIterator.hasNext()) {
String key = (String) propertiesIterator.next();
cmdLine.createArgument().setValue("-D" + key + "=" + buildProperties.get(key));
}
if (LOG.isDebugEnabled()) {
cmdLine.createArgument().setValue("-X");
}
cmdLine.createArgument().setValue("-b"); // no banner
if (projectFile != null) {
// we need only the name of the file
File pFile = new File(projectFile);
cmdLine.createArgument().setValue("-p");
cmdLine.createArgument().setValue(pFile.getName());
}
if (goalset != null) {
StringTokenizer stok = new StringTokenizer(goalset, " \t\r\n");
while (stok.hasMoreTokens()) {
cmdLine.createArgument().setValue(stok.nextToken());
}
}
if (LOG.isDebugEnabled()) {
StringBuffer sb = new StringBuffer();
sb.append("Executing Command: ");
String[] args = cmdLine.getCommandline();
for (int i = 0; i < args.length; i++) {
String arg = args[i];
sb.append(arg);
sb.append(" ");
}