Maven Antlr3 plugin generates code in weird location

659 Views Asked by At

I am using plugin and Antlr version 3.3 for a project under H:/compiler

I have a tokens file under my src/main/antlr3/com/cbc/example directory called CBCTokens.g. In the same package i have a parser grammar file called MyScribe.g that references the tokens using tokenVocab=CBCTokens. I also have a tree grammar in the same directory.

However when i try to execute the build, i get an error on the very first file the plugin encounters saying:

Error(1): cannot write file : java.io.FileNotFoundException: H:\compiler\target\generated-sources\antlr3\H:\compiler\src\main\antlr3\CBCTokensLexer.java (The filname, directory name, or volume label syntax is incorrect)

It seems to me that the plugin is determining the output path using some weird combination of baseDir and the default output directory.

What configuration am i missing?

Thanks

1

There are 1 best solutions below

1
On

First best thing is never to generate code into src/main/ folder whatever. This means for your configuration just remove <outputDirectory> tag and remove the <sourceDirectory> cause it's the default of the antlr3-maven-plugin.

<build>
  <plugins>
    <plugin>
      <groupId>org.antlr</groupId>
      <artifactId>antlr3-maven-plugin</artifactId>
      <version>3.3</version>
      <configuration>
        <printGrammar>false</printGrammar>
        <verbose>true</verbose>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>antlr</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>