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

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>

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


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>

Tags:

Maven

Antlr4