Antlr4 Maven ANTLR生成错误的目录
我有以下pom.xml文件:Antlr4 Maven ANTLR生成错误的目录,antlr4,Antlr4,我有以下pom.xml文件: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>db.project</groupId>
<artifactId>engine</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<antlr4.visitor>true</antlr4.visitor>
<antlr4.listener>true</antlr4.listener>
</properties>
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.0</version>
<configuration>
<sourceDirectory>src</sourceDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
4.0.0
db.project
. 但我现在想使用maven,当我在com.db.project目录中更新语法时,解析器和语法分析器会在默认包(即src/default包)和src/com/db/project/中生成两次,而我只想在src/com/db/project/目录中生成语法分析器和语法分析器。(包括同一包中的.g4文件和java文件)
如何通过pom.xml更改此项?在您的antlr4 maven插件的版本标签中将4.0
简单更改为4.2
请注意,插件将递归扫描src/main/antlr4
中的.g4
语法文件。如果语法位于src/main/antlr4/com/company
中,则生成的解析器/词法分析器文件包将是com.company
以下是一个小模板项目,以备您需要:
您是否尝试过4.2版的antlr4 maven插件?在那个版本中,我对Maven集成做了重大改进。您好@280Z28,我还没有尝试过Antlr4.2。我如何使用它?它能解决我的问题吗?事实上,我现在有一个问题@bart kiers,我做了同样的事情,但我仍然得到了两个lexer解析器文件(一个在(默认包)中,另一个在src/db/propect中)。我还创建了target/generated sources/anltr4/db/project目录,我的语法也在其中生成了它的lexer和parser文件。我怎样才能忽略语法以避免在默认包和src/db/project中都生成语法呢。我只希望我的lexer解析器位于target/generated sources/antl4/db/project目录中。我只处理mvn安装和生成源代码。也就是说,当我保存语法时,语法不会生成它的lexer解析器,我必须运行mvn generate sources或mvn install。你有更好的方法吗?不,我没有其他方法:当更改语法时,你必须执行mvn生成源代码或mvn安装。但是当我保存语法时,你的语法(antlr4模板)可以工作。我只是不明白我的项目本身有什么错误:/