我有一个Maven项目,使用Antlr 4生成一些源代码。目录结构如下:
- pom.xml
- src
+- main
| +- antlr4
| | +- mypackage
| | +- MyGrammar.g4
| +- java
| +- mypackage
+- target
+- generated-sources
+- antlr4
+- mypackage
+- MyGrammarParser.java
+- ... etc
这大部分都有效。但时不时 Intellij会将src/target/generated-sources/antlr4/mypackage
视为生成的源目录,而不仅仅是src/target/generated-sources/antlr4/
,我必须手动更改它。
有没有办法解决这个问题,以便Intellij不会尝试更改生成的源目录?
我的POM包含:
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.5</version>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
<configuration>
<listener>true</listener>
<visitor>true</visitor>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
<version>4.5</version>
</dependency>
</dependencies>