bodewig 2003/04/01 06:44:00
Modified: . WHATSNEW
docs/manual/OptionalTasks antlr.html
src/main/org/apache/tools/ant/taskdefs/optional ANTLR.java
Log:
Recompile grammar if supergrammar has changed.
PR: 12961
Revision Changes Path
1.383 +3 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.382
retrieving revision 1.383
diff -u -r1.382 -r1.383
--- WHATSNEW 31 Mar 2003 12:27:13 -0000 1.382
+++ WHATSNEW 1 Apr 2003 14:44:00 -0000 1.383
@@ -76,6 +76,9 @@
* The <stripjavacomments> filter sometimes removed parts of string
constants. Bugzilla Report 17441.
+* <antlr> will now recompile your grammar if the supergrammar has
+ changed. Bugzilla Report 12691.
+
Other changes:
--------------
* Shipped XML parser is now Xerces 2.4.0
1.11 +12 -4 ant/docs/manual/OptionalTasks/antlr.html
Index: antlr.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/OptionalTasks/antlr.html,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- antlr.html 4 Sep 2002 11:05:18 -0000 1.10
+++ antlr.html 1 Apr 2003 14:44:00 -0000 1.11
@@ -21,10 +21,11 @@
the grammar file.
</p>
<p>
- This task only invokes ANTLR if the grammar file is newer than the generated
- files.
+ This task only invokes ANTLR if the grammar file (or the
+ supergrammar specified by the glib attribute) is newer than the
+ generated files.
</p>
-<p>
+<p>Antlr 2.7.1 Note:
<i>
To successfully run ANTLR, your best option is probably to build the whole
jar with the provided script <b>mkalljar</b> and drop the resulting jar (about
300KB)
@@ -33,6 +34,13 @@
to your classpath as described in ANTLR <tt>install.html</tt> document.
</i>
</p>
+<p>Antlr 2.7.2 Note:
+<i>
+ Instead of the above, you will need antlrall.jar that can be created
+ by the <b>antlr-all.jar</b> target of the Makefile provided with the
+ download.
+</i>
+</p>
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
@@ -170,7 +178,7 @@
</p>
<hr>
-<p align="center">Copyright © 2000-2002 Apache Software Foundation. All
rights
+<p align="center">Copyright © 2000-2003 Apache Software Foundation. All
rights
Reserved.</p>
</body>
1.23 +12 -4 ant/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
Index: ANTLR.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ANTLR.java 1 Apr 2003 14:33:28 -0000 1.22
+++ ANTLR.java 1 Apr 2003 14:44:00 -0000 1.23
@@ -276,10 +276,18 @@
validateAttributes();
//TODO: use ANTLR to parse the grammer file to do this.
File generatedFile = getGeneratedFile();
- if (target.lastModified() > generatedFile.lastModified()) {
- log("Compiling " + target + " as it is newer than "
- + generatedFile, Project.MSG_VERBOSE);
-
+ boolean targetIsOutOfDate =
+ target.lastModified() > generatedFile.lastModified();
+ boolean superGrammarIsOutOfDate = superGrammar != null &&
+ (new File(superGrammar).lastModified() > generatedFile.lastModified());
+ if (targetIsOutOfDate || superGrammarIsOutOfDate) {
+ if (targetIsOutOfDate) {
+ log("Compiling " + target + " as it is newer than "
+ + generatedFile, Project.MSG_VERBOSE);
+ } else if (superGrammarIsOutOfDate) {
+ log("Compiling " + target + " as " + superGrammar
+ + " is newer than " + generatedFile, Project.MSG_VERBOSE);
+ }
populateAttributes();
commandline.createArgument().setValue(target.toString());
|