|
@@ -161,6 +161,8 @@ public class Main { |
|
|
|
|
|
|
|
|
protected Main(String[] args) throws BuildException { |
|
|
protected Main(String[] args) throws BuildException { |
|
|
|
|
|
|
|
|
|
|
|
String searchForThis = null; |
|
|
|
|
|
|
|
|
// cycle through given args |
|
|
// cycle through given args |
|
|
|
|
|
|
|
|
for (int i = 0; i < args.length; i++) { |
|
|
for (int i = 0; i < args.length; i++) { |
|
@@ -238,7 +240,7 @@ public class Main { |
|
|
if (posEq > 0) { |
|
|
if (posEq > 0) { |
|
|
value = name.substring(posEq+1); |
|
|
value = name.substring(posEq+1); |
|
|
name = name.substring(0, posEq); |
|
|
name = name.substring(0, posEq); |
|
|
} else if (i < args.length) |
|
|
|
|
|
|
|
|
} else if (i < args.length-1) |
|
|
value = args[++i]; |
|
|
value = args[++i]; |
|
|
|
|
|
|
|
|
definedProps.put(name, value); |
|
|
definedProps.put(name, value); |
|
@@ -253,6 +255,13 @@ public class Main { |
|
|
} else if (arg.equals("-projecthelp")) { |
|
|
} else if (arg.equals("-projecthelp")) { |
|
|
// set the flag to display the targets and quit |
|
|
// set the flag to display the targets and quit |
|
|
projectHelp = true; |
|
|
projectHelp = true; |
|
|
|
|
|
} else if (arg.equals("-find")) { |
|
|
|
|
|
// eat up next arg if present, default to build.xml |
|
|
|
|
|
if (i < args.length-1) { |
|
|
|
|
|
searchForThis = args[++i]; |
|
|
|
|
|
} else { |
|
|
|
|
|
searchForThis = DEFAULT_BUILD_FILENAME; |
|
|
|
|
|
} |
|
|
} else if (arg.startsWith("-")) { |
|
|
} else if (arg.startsWith("-")) { |
|
|
// we don't have any more args to recognize! |
|
|
// we don't have any more args to recognize! |
|
|
String msg = "Unknown arg: " + arg; |
|
|
String msg = "Unknown arg: " + arg; |
|
@@ -267,9 +276,13 @@ public class Main { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// if buildFile was not specified on the command line, |
|
|
// if buildFile was not specified on the command line, |
|
|
// then search for it |
|
|
|
|
|
if (buildFile == null) { |
|
|
if (buildFile == null) { |
|
|
buildFile = findBuildFile(DEFAULT_BUILD_FILENAME); |
|
|
|
|
|
|
|
|
// but -find then search for it |
|
|
|
|
|
if (searchForThis != null) { |
|
|
|
|
|
buildFile = findBuildFile(".", searchForThis); |
|
|
|
|
|
} else { |
|
|
|
|
|
buildFile = new File(DEFAULT_BUILD_FILENAME); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// make sure buildfile exists |
|
|
// make sure buildfile exists |
|
@@ -289,18 +302,6 @@ public class Main { |
|
|
readyToRun = true; |
|
|
readyToRun = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Helper to get the parent file for a given filename. |
|
|
|
|
|
* |
|
|
|
|
|
* <P>Added to simulate File.getParentFile() from JDK 1.2. |
|
|
|
|
|
* |
|
|
|
|
|
* @param filename File name |
|
|
|
|
|
* @return Parent file or null if none |
|
|
|
|
|
*/ |
|
|
|
|
|
private File getParentFile(String filename) { |
|
|
|
|
|
return getParentFile(new File(filename)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Helper to get the parent file for a given file. |
|
|
* Helper to get the parent file for a given file. |
|
|
* |
|
|
* |
|
@@ -334,12 +335,12 @@ public class Main { |
|
|
* |
|
|
* |
|
|
* @exception BuildException Failed to locate a build file |
|
|
* @exception BuildException Failed to locate a build file |
|
|
*/ |
|
|
*/ |
|
|
private File findBuildFile(String suffix) throws BuildException { |
|
|
|
|
|
|
|
|
private File findBuildFile(String start, String suffix) throws BuildException { |
|
|
if (msgOutputLevel >= Project.MSG_INFO) { |
|
|
if (msgOutputLevel >= Project.MSG_INFO) { |
|
|
System.out.println("Searching for " + suffix + " ..."); |
|
|
System.out.println("Searching for " + suffix + " ..."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
File parent = getParentFile(suffix); |
|
|
|
|
|
|
|
|
File parent = new File(new File(start).getAbsolutePath()); |
|
|
File file = new File(parent, suffix); |
|
|
File file = new File(parent, suffix); |
|
|
|
|
|
|
|
|
// check if the target file exists in the current directory |
|
|
// check if the target file exists in the current directory |
|
@@ -503,6 +504,8 @@ public class Main { |
|
|
msg.append(" -listener <classname> add an instance of class as a project listener" + lSep); |
|
|
msg.append(" -listener <classname> add an instance of class as a project listener" + lSep); |
|
|
msg.append(" -buildfile <file> use given buildfile" + lSep); |
|
|
msg.append(" -buildfile <file> use given buildfile" + lSep); |
|
|
msg.append(" -D<property>=<value> use value for given property" + lSep); |
|
|
msg.append(" -D<property>=<value> use value for given property" + lSep); |
|
|
|
|
|
msg.append(" -find <file> search for buildfile towards the root of the file" + lSep); |
|
|
|
|
|
msg.append(" system and use it" + lSep); |
|
|
System.out.println(msg.toString()); |
|
|
System.out.println(msg.toString()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|