Browse Source

added a special case that detects -cp and -lib calls in Main, and tells the caller that they have a probable version mismatch.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278263 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 20 years ago
parent
commit
923140f496
1 changed files with 13 additions and 21 deletions
  1. +13
    -21
      src/main/org/apache/tools/ant/Main.java

+ 13
- 21
src/main/org/apache/tools/ant/Main.java View File

@@ -29,6 +29,7 @@ import java.util.Vector;
import org.apache.tools.ant.input.DefaultInputHandler; import org.apache.tools.ant.input.DefaultInputHandler;
import org.apache.tools.ant.input.InputHandler; import org.apache.tools.ant.input.InputHandler;
import org.apache.tools.ant.launch.AntMain; import org.apache.tools.ant.launch.AntMain;
import org.apache.tools.ant.util.FileUtils;




/** /**
@@ -212,20 +213,8 @@ public class Main implements AntMain {
*/ */
private static void handleLogfile() { private static void handleLogfile() {
if (isLogFileUsed) { if (isLogFileUsed) {
if (out != null) {
try {
out.close();
} catch (final Exception e) {
//ignore
}
}
if (err != null) {
try {
err.close();
} catch (final Exception e) {
//ignore
}
}
FileUtils.close(out);
FileUtils.close(err);
} }
} }


@@ -424,6 +413,15 @@ public class Main implements AntMain {
throw new BuildException( throw new BuildException(
"Niceness value is out of the range 1-10"); "Niceness value is out of the range 1-10");
} }
} else if (arg.equals("-cp") || arg.equals("-lib")) {
//catch script/ant mismatch with a meaningful message
//we could ignore it, but there are likely to be other
//version problems, so we stamp down on the configuration now
String msg = "Ant's Main method is being handed "
+ "an option "+arg+" that is only for the launcher class."
+ "\nThis can be caused by a version mismatch between "
+ "the ant script/.bat file and Ant itself.";
throw new BuildException(msg);
} 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 argument: " + arg; String msg = "Unknown argument: " + arg;
@@ -476,13 +474,7 @@ public class Main implements AntMain {
System.out.println("Could not load property file " System.out.println("Could not load property file "
+ filename + ": " + e.getMessage()); + filename + ": " + e.getMessage());
} finally { } finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
// ignore
}
}
FileUtils.close(fis);
} }


// ensure that -D properties take precedence // ensure that -D properties take precedence


Loading…
Cancel
Save