[antlr-interest] ANTLR 3.0.1 build failure

Wincent Colaiuta win at wincent.com
Tue Oct 16 11:57:02 PDT 2007


El 16/10/2007, a las 7:08, Wincent Colaiuta <win at wincent.com> escribió:

> El 16/10/2007, a las 2:32, Terence Parr escribió:
>
>> On Oct 15, 2007, at 4:27 PM, Wincent Colaiuta wrote:
>>
>>> I've run into the exact same problem as Kenny did last month
>>> trying to build ANTLR 3.0.1:
>>>
>>> <http://www.antlr.org/pipermail/antlr-interest/2007-September/
>>> 023639.html>
>>>
>>> Nobody replied back then, and I'm at the limit of my ant
>>> troubleshooting skills. Anybody know how to fix this?
>>
>> Weird.  I guess you can try the old javac *.java in the dirs ;)
>> Ter
>
> I found out a bit more by passing the "-v" (verbose) switch to "ant
> build". If you look at the list of files it says it will compile
> (pasted below), you can see that the last 13 are duplicates. I know
> absolutely nothing about Ant and the XML build file, so I tried a
> cave-man troubleshooting technique: moving the duplicate files out of
> the way. Moving the files in the "codegen" subdirectory (the ones at
> the end of the list) didn't work and just yielded different errors,
> but moving the other duplicates out of the way (the ones in "src/org/
> antlr/tool" and "src/org/antlr/codegen") made the build succeed.

I've done a little more research on the build problem and have  
observed the following:

- on issuing an "ant build" the first target to be built is the  
"generator-prepare" target; this copies some ".g" files into the top- 
level "codegen" dir

- the next target is "generator", which fails unless antlr-2.7.7.jar  
is in the CLASSPATH; this generates a bunch of java files in the  
"codegen" dir which are identical to those stored elsewhere in the  
source tree, apart from the embedded timestamps

- the next target is "compile-rt", which goes fine

- then comes "compile", which is where the duplicate class warnings  
are produced; it looks like this happens because the "src.path" in  
the build.xml file comprises both the "codegen.dir" (where the new  
java files just got created) and the "src.dir" (where the original  
copies reside)

So it appears that there are two possible fixes:

- either to edit the build.xml file to add some sort of (possibly  
complex) logic to exclude any java file in the "src.dir" which is  
also in the "codegen.dir"

- or change the source distribution to exclude the duplicate files,  
seeing as they're never used anyway

In any case, this is the build script I am using now to do a build:

#!/bin/sh
ANTLR_VERSION="antlr-3.0.1"
rm -rf "${ANTLR_VERSION}"
tar xzvf "${ANTLR_VERSION}.tar.gz"
OLD_CLASSPATH="$CLASSPATH"
export CLASSPATH="/usr/local/junit/junit.jar:./lib/antlr-2.7.7.jar"
cd "${ANTLR_VERSION}"
ant generator
cd codegen
FILES=`ls *.java`
cd ..
for FILE in $FILES
do
    find src/org/antlr -name $FILE -delete
done
ant build
export CLASSPATH="$OLD_CLASSPATH"

Cheers,
Wincent





More information about the antlr-interest mailing list