sbailliez 01/12/15 10:53:39
Modified: src/testcases/org/apache/tools/ant/taskdefs/optional
ANTLRTest.java
src/main/org/apache/tools/ant/taskdefs/optional ANTLR.java
Log:
Update ANTLR to revert to forked-mode only.
Comments in code should be self explanatory for the
next person who have to deal with it.
Testcase is updated (working dir is no more mandatory)
and I added a note in case someone wants to run
the tests... I should probably add a mention to
this in the ANTLR docs.
Revision Changes Path
1.6 +11 -1
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java
Index: ANTLRTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ANTLRTest.java 2001/11/14 12:25:31 1.5
+++ ANTLRTest.java 2001/12/15 18:53:39 1.6
@@ -57,6 +57,16 @@
import java.io.*;
import org.apache.tools.ant.BuildFileTest;
/**
+ * If you want to run tests, it is highly recommended
+ * to download ANTLR (www.antlr.org), build the 'all' jar
+ * with the mkalljar script and drop the jar (about 300KB) into
+ * Ant lib.
+ * - Running w/ the default antlr.jar (70KB) does not work (missing class)
+ * - Running w/ the antlr jar made w/ mkjar (88KB) does not work (still
another class missing)
+ *
+ * Unless of course you specify the ANTLR classpath in your
+ * system classpath. (see ANTLR install.html)
+ *
* @author Erik Meade <[EMAIL PROTECTED]>
*/
public class ANTLRTest extends BuildFileTest {
@@ -91,7 +101,7 @@
}
public void test5() {
- expectBuildException("test5", "Invalid working directory");
+ executeTarget("test5");
}
public void test6() {
1.6 +13 -20
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
Index: ANTLR.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ANTLR.java 2001/12/15 00:27:16 1.5
+++ ANTLR.java 2001/12/15 18:53:39 1.6
@@ -89,7 +89,7 @@
private File outputDirectory;
/** should fork ? */
- private boolean fork = false;
+ private final boolean fork = true;
/** working directory */
private File workingdir = null;
@@ -109,8 +109,13 @@
this.outputDirectory = outputDirectory;
}
+ // we are forced to fork ANTLR since there is a call
+ // to System.exit() and there is nothing we can do
+ // right now to avoid this. :-( (SBa)
+ // I'm not removing this method to keep backward compatibility
+ // and
public void setFork(boolean s) {
- this.fork = s;
+ //this.fork = s;
}
/**
@@ -180,31 +185,19 @@
public void execute() throws BuildException {
validateAttributes();
-
//TODO: use ANTLR to parse the grammer file to do this.
if (target.lastModified() > getGeneratedFile().lastModified()) {
commandline.createArgument().setValue("-o");
commandline.createArgument().setValue(outputDirectory.toString());
commandline.createArgument().setValue(target.toString());
- if (fork) {
- log("Forking " + commandline.toString(),
Project.MSG_VERBOSE);
- int err = run(commandline.getCommandline());
- if (err == 1) {
- throw new BuildException("ANTLR returned: "+err,
location);
- }
- } else {
- ExecuteJava exe = new ExecuteJava();
- exe.setJavaCommand(commandline.getJavaCommand());
- exe.setClasspath(commandline.getClasspath());
- try {
- exe.execute(project);
- } catch (ExitException e){
- if ( e.getStatus() != 0 ){
- throw new BuildException("ANTLR returned: " +
e.getStatus(), location);
- }
- }
+ log("Forking " + commandline.toString(), Project.MSG_VERBOSE);
+ int err = run(commandline.getCommandline());
+ if (err == 1) {
+ throw new BuildException("ANTLR returned: "+err, location);
}
+ } else {
+ log("Skipped grammar file. Generated file is newer.",
Project.MSG_VERBOSE);
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>