[antlr-interest] Maven vs AntlrWorks Generated Sources

Ramirez, Paul M (388J) paul.m.ramirez at jpl.nasa.gov
Wed Sep 30 06:27:37 PDT 2009


Hey All,

Just wanted to bring this topic back around to the original question I had. If set up correctly, what would cause the maven plugin to generate different source then antlrworks (50k lines vs 8k for the parser)? I have left the configuration to the defaults for the maven plugin. Right now I have to generate sources with antlrworks because the compiler won't work on the (50k line java file).

Thanks,
Paul Ramirez


On 9/30/09 2:47 AM, "Luca Li Greci" <luca.ligreci at gmail.com> wrote:



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 <http://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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090930/e13eb6ba/attachment.html 


More information about the antlr-interest mailing list