Generate test-jar along with jar file in test package

回眸只為那壹抹淺笑 提交于 2019-11-26 16:33:23

问题


I want to package my test package to jar file . How to execute generate test-jar from maven plugin Surefire.


回答1:


You can add following entries to your 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>



回答2:


By using the following configuration you can create a jar from your tests:

  <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>

To use such kind of artifact:

  <dependencies>
    <dependency>
      <groupId>groupId</groupId>
      <artifactId>artifactId</artifactId>
      <type>test-jar</type>
      <version>version</version>
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>
  </dependencies>


来源:https://stackoverflow.com/questions/12828416/generate-test-jar-along-with-jar-file-in-test-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!