【发布时间】:2012-10-10 21:11:36
【问题描述】:
我想将我的测试包打包成 jar 文件。如何从 maven 插件 Surefire 执行生成 test-jar。
【问题讨论】:
标签: maven maven-surefire-plugin
我想将我的测试包打包成 jar 文件。如何从 maven 插件 Surefire 执行生成 test-jar。
【问题讨论】:
标签: maven maven-surefire-plugin
通过使用以下配置,您可以从测试中创建一个 jar:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
要使用这种神器:
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<type>test-jar</type>
<version>version</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
【讨论】:
您可以在 pom 中添加以下条目:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
【讨论】: