Generate test-jar along with jar file in test package

后端 未结 2 1100
暗喜
暗喜 2020-12-03 05:24

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

相关标签:
2条回答
  • 2020-12-03 05:37

    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>
    
    0 讨论(0)
  • 2020-12-03 05:50

    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>
    
    0 讨论(0)
提交回复
热议问题