给定由以下人员生成的 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
cf: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 集成(但是,如果这是唯一的方法,我肯定会选择这个)。