Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the format for specifying a package in the Antlr4 maven plugin?

Tags:

maven

antlr4

What is the format for specifying a package in the Antlr4 maven plugin antlr4-maven-plugin?

I feel like I should be able to do the following:

<plugin>
    <groupId>com.tunnelvisionlabs</groupId>
    <artifactId>antlr4-maven-plugin</artifactId>
    <version>4.0</version>
    <configuration>
        <arguments>package my.package.name</arguments>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>antlr4</goal>
            </goals>
        </execution>
    </executions>
</plugin>

but that results in the following error:

[ERROR] Failed to execute goal com.tunnelvisionlabs:antlr4-maven-plugin:4.0:antlr4 (default) on project my_project: Unable to parse configuration of mojo com.tunnelvisionlabs:antlr4-maven-plugin:4.0:antlr4 for parameter arguments: Cannot assign configuration entry 'arguments' with value 'package my.package.name' of type java.lang.String to property of type java.util.List -> [Help 1]
like image 400
Brian Kent Avatar asked Aug 14 '13 22:08

Brian Kent


3 Answers

If I am you, I will make a maven project per package and try this

<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.0</version>
<configuration>
    <sourceDirectory>${basedir}/src</sourceDirectory>
</configuration>
<executions>
    <execution>
        <goals>
            <goal>antlr4</goal>
        </goals>
    </execution>
</executions>
</plugin>

but usually, When I pass an argument in maven configuration, I do the following. but I am not sure of that syntax in antlr4

<plugin>
<groupId>com.tunnelvisionlabs</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.0</version>
<configuration>
    <arguments>
      <argument>-package</argument>
      <argument>my.package.name</argument>

   </arguments>
</configuration>
<executions>
    <execution>
        <goals>
            <goal>antlr4</goal>
        </goals>
    </execution>
</executions>
</plugin>

Edit: Notice the - in front of package so the antlr-maven-plugin will recognize it as a parameter

like image 172
mebada Avatar answered Oct 06 '22 18:10

mebada


The package is automatically determined based on the location of the file in your project, similar to the way the package is determined for Java files. The output is also placed in a location determined by the location of the source file. To change the package where the code is generated, you'll need to move the grammar file.

Other arguments can be specified like this:

<arguments>
  <argument>arg1</argument>
  <argument>arg2</argument>
</arguments>
like image 33
Sam Harwell Avatar answered Oct 06 '22 17:10

Sam Harwell


Your configuration arguments syntax is wrong.

Please change the configuration of antlr4-maven-plugin from

<configuration>
    <arguments>package my.package.name</arguments>
</configuration>

to:

<configuration>
    <arguments>
        <argument>-package</argument>
        <argument>my.package.name</argument>
    </arguments>
</configuration>
like image 39
dongpf Avatar answered Oct 06 '22 19:10

dongpf