[antlr-interest] Maven vs AntlrWorks Generated Sources

Jim Idle jimi at temporal-wave.com
Tue Sep 29 12:42:49 PDT 2009


On 09/29/2009 12:35 PM, Luca Li Greci wrote:
>
> <plugin>
> <groupId>org.antlr</groupId>
> <artifactId>antlr3-maven-plugin</artifactId>
> <version>3.1.3-1</version>
> <executions>
> <execution>
> <id>parser</id>
> <phase>generate-sources</phase>
> <goals>
> <goal>antlr</goal>
> </goals>
> <configuration>
> <sourceDirectory>src/main/resources/antlr3</sourceDirectory>
> <libDirectory>src/main/resources/antlr3*/org/mycompany/myproduct*</libDirectory>
> <outputDirectory>target/generated-sources/antlr3</outputDirectory>
> <includes>
> <include>***/myGrammar*.g*</include>
> </includes>
> </configuration>
> </execution>
> </executions>
> </plugin>
>
> As you can see under src/main/resources/antlr3 I created a "package 
> structure" of subfolder and inside myproduct I put all my grammars.
>
> In this way I keep in synch what is generated as subdirectories with 
> what I declared inside the grammar file, for instance
>
> @parser::header {package org.mycompany.myproduct;}
>
> If you don't do that you have a weird situation where the code is 
> generate in the default package (top level), and in the code there's 
> the package definition.... it doesn't compile.

Hi - you should avoid setting up your own structure under source and use 
the pre-known locations of the .g files. Read the docs at 
www.antlr.org/antlr3-maven-plugin. The .g files should go under the 
antlr directory and they should be in sub directories of this directory 
that reflect the package structure you want for the generated files. 
Include and lib, as well as import is then calculated automatically.

Also note that we are at ANTLR 3.2 and plugin 3.2 now, though I think 
that Maven central is not syncing our repository right now and I have no 
time to try and work out why.

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090929/b46dee87/attachment.html 


More information about the antlr-interest mailing list