Antlr4 Maven 配置
<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>com.example</groupId>
<artifactId>antlr4-maven-example</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- 添加 ANTLR4 运行时依赖 -->
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.9.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 添加 ANTLR4 Maven 插件 -->
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.9.2</version>
<configuration>
<!-- 指定 ANTLR 语法文件的位置 -->
<sourceDirectory>src/main/antlr4</sourceDirectory>
<!-- 指定生成的 Java 文件存放的位置 -->
<outputDirectory>src/main/java</outputDirectory>
<!-- 生成监听器和支持访问者模式的代码 -->
<arguments>
<argument>-visitor</argument>
<argument>-listener</argument>
</arguments>
</configuration>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>