Compilation error on antlr3 files in Eclipse 2022-09

73 Views Asked by At

Eclipse version: 2022-09

Eclipse m2e version: 2.0.4

antlr version: 3

antlr3-maven-plugin: 3.5.3

I have a project with a Logic.g file. Everything was working OK on a previous version of Eclipse (where I had installed an m2e antlr connector), meaning the file would be converted to target/generated-sources/antlr3 (LogicLexer.java and LogicParser.java), and somehow be picked up by Eclipse and compile a Logic.tokens file in target, and the LogicLexer.class and LogicParser.class within target.

In Eclipse 2022-09 however, my test classes that use either LogicLexer or LogicParser yield a compilation error in Errors "cannot be resolved to a type".

It's just a problem in Eclipse (nothing changed in the code, and a maven verify works correctly).

The tokens file and the .class are being generated as long as I have the lifecycleMappingMetadata configured (see snippet below).

Question: How can I make the Eclipse project see these compiled classes and remove the compilation errors?

<build>
    <plugins>
        <plugin>
            <groupId>org.antlr</groupId>
            <artifactId>antlr3-maven-plugin</artifactId>
            <version>3.5.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>antlr</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
        </plugin>
    </plugins>
        <pluginManagement>
  <plugins>
    <!--This plugin's configuration is used to store Eclipse m2e settings 
      only. It has no influence on the Maven build itself. -->
    <plugin>
      <groupId>org.eclipse.m2e</groupId>
      <artifactId>lifecycle-mapping</artifactId>
      <version>1.0.0</version>
      <configuration>
        <lifecycleMappingMetadata>
          <pluginExecutions>
            <pluginExecution>
              <pluginExecutionFilter>
                <groupId>org.antlr</groupId>
                <artifactId>antlr3-maven-plugin</artifactId>
                <versionRange>[3.5.3,)</versionRange>
                <goals>
                  <goal>antlr</goal>
                </goals>
              </pluginExecutionFilter>
              <action>
                <execute>
                  <runOnIncremental>true</runOnIncremental>
                </execute>
              </action>
            </pluginExecution>
          </pluginExecutions>
        </lifecycleMappingMetadata>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>
0

There are 0 best solutions below