给定生成的 Maven 项目:
mvn archetype:generate -B -DarchetypeGroupId=org.antlr \
-DarchetypeArtifactId=antlr3-maven-archetype \
-DarchetypeVersion=3.2 \
-DgroupId=com.yourcompany \
-DartifactId=yourproject \
-Dversion=yourversion \
-Dpackage=com.yourcompany.package.path
对比:http://www.antlr.org/wiki/display/ANTLR3/Building+ANTLR+Projects+with+Maven
有这样的架构:
.
|-- pom.xml
`-- src
`-- main
|-- antlr3
| |-- com
| | `-- yourcompany
| | `-- package
| | `-- path
| | |-- TLexer.g
| | |-- TParser.g
| | `-- TTree.g
| `-- imports
| `-- Ruleb.g
`-- java
`-- com
`-- yourcompany
`-- package
`-- path
|-- AbstractTLexer.java
|-- AbstractTParser.java
`-- Main.java
通过将 maven-gunit-plugin 添加到 pom 中:
<plugin>
<groupId>org.antlr</groupId>
<artifactId>maven-gunit-plugin</artifactId>
<version>3.2</version>
<executions>
<execution>
<id>maven-gunit-plugin</id>
<phase>test</phase>
<goals>
<goal>gunit</goal>
</goals>
</execution>
</executions>
</plugin>
GUNIT 文件应该在哪里?
更新(已经):
我不是在谈论 Junit 集成(但是,如果这是唯一的方法,我一定会选择这个)。
最佳答案
来源的相关部分告诉我它使用 ${basedir}/src/test/gunit。对于文件,它使用私有(private)变量 includes 或 */.testsuite(如果 includes 未定义)。 maven-gunit-plugin 似乎无法处理 JUnit 与 3.2 的集成。
关于java - 如何将 GUNIT 与 MAVEN 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3750121/