[antlr-interest] Maven vs AntlrWorks Generated Sources

Luca Li Greci luca.ligreci at gmail.com
Wed Sep 30 02:47:45 PDT 2009


2009/9/29 Jim Idle <jimi at temporal-wave.com>

>  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
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>

Hi Jim,

Let me see if my understanding is correct.

You said that when the grammar is under src/main/antlr3* *the maven plugin
automatically picks up all grammar defined under any subdirectories (such
as org/mycompany/myproduct) so that the maven parameters include, lib, and
the @parser::header {package org.mycompany.myproduct;} are useless. Is it my
understanding correct ?

Thanks Jim for your clarification

-- 
Victor Hugo wrote, “The future has many names: For the weak, it means the
unattainable. For the fearful, it means the unknown. For the courageous, it
means opportunity.”
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090930/4bbbf1d5/attachment.html 


More information about the antlr-interest mailing list