[antlr-interest] maven antlr3 plugin

Dominique de Waleffe ddewaleffe at gmail.com
Wed Apr 8 09:14:58 PDT 2009


I am trying to move away from using antrun tasks and patching my local
maven repository with antlr files in order to ease the move my
application to s.o. else in a different organization.

I used to have ant tasks run by maven as shown below:

 <taskdef classname="org.apache.tools.ant.antlr.ANTLR3"
name="antlr:antlr3" classpathref="maven.plugin.classpath" />
 <antlr:antlr3 outputdirectory="src/main/java/WebObjects/Core"
target="src/main/antlr/commandline.g"
xmlns:antlr="antlib:org/apache/tools/ant/antlr">
 <classpath>
 <path refid="antlr.path" />
 </classpath>
 </antlr:antlr3>

I found the description of the new plugin on
http://antlr.org/antlr3-maven-plugin/project-info.html
and thought this would be just what I need.

So I removed the old ant stuff and added:
      <plugin>
        <groupId>org.antlr</groupId>
        <artifactId>antlr3-maven-plugin</artifactId>
	<version>3.1.3-1</version>
	<executions>
          <execution>
            <configuration>
              <goals>
                <goal>antlr</goal>
              </goals>
	      <verbose>true</verbose>
	      <libDirectory>${basedir}/src/main/antlr/imports</libDirectory>
	      <outputDirectory>${basedir}/src/main/java/WebObjects/Core</outputDirectory>
	      <sourceDirectory>${basedir}/src/main/antlr</sourceDirectory>
	    </configuration>
	  </execution>
	</executions>
      </plugin>

Now some things happen, which is good, but not yet what I expected...
I get the following trace, and questions...

[INFO] Building BIExperiment
[INFO]    task-segment: [antlr3:antlr]
[INFO] ------------------------------------------------------------------------
[INFO] [antlr3:antlr]
error(3):  cannot find tokens file
h:\bio\BioEmergences\BIExperiment\target\generated-sources\antlr\Pipeline.tokens
[INFO] Processing grammar
h:\bio\BioEmergences\BIExperiment\src\main\antlr\StatsFromLogs.g
[INFO] Processing grammar
h:\bio\BioEmergences\BIExperiment\src\main\antlr\Pipeline.g
[INFO] Processing grammar
h:\bio\BioEmergences\BIExperiment\src\main\antlr\PipelineWalker.g
[INFO] Processing grammar
h:\bio\BioEmergences\BIExperiment\src\main\antlr\commandline.g
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL

1. I do not see where the error message comes from, except that
   grammars might be processed in an incorrect order, but this is not
   obvious from the trace (Pipeline.g is processed before
   PipelineWalker.g)...

2. Do I have to create several <execution/> to force an ordering?

3. Despite setting outputDirectory, the generated files end up in
   target/generated-sources/antlr. Looks like a bug or unimplemented
   feature. What is the status?

4. The <verbose>true</verbose> flag does not seem to produce any more
   output than without it...

Thanks for hints...

D.

--
Dominique de Waleffe
ddewaleffe -at- gmail -dot- com


More information about the antlr-interest mailing list