Apologies if this has been asked before. My quick search could not find any such thread.
I am using:
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.2.2</version>
<type>maven-plugin</type>
</dependency>
...
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.2.2</version>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
<configuration>
<sourceDirectory>src/main/antlr</sourceDirectory>
</configuration>
</execution>
</executions>
</plugin>
I have arranged my grammar in the following dir structure:
/fooparser/src/main/antlr/com/foo/Filter.g4
On mvn compile antlr recognizes the directory structure and automatically spits out package at the top of the generated java files:
package com.foo;
Now if I want to explicitly specify the package line in @header it spits out two package lines and the compilation fails.
@header {
package com.foo;
}
Generated java file starts with:
package com.foo; <- automatically generated
package com.foo; <- from @header
How can I workaround this? I have another build system to support besides maven, which I think (??? I am yet to confirm this) is using different version of antlr and it doesn't spit out the package line automatically. That is why I am looking for this workaround.
Please let me know if there is a way to turn off automatic spitting out of package line and depend on me to specify it in the @header.
Thanks!
Vinod.