我正在使用maven-jar-plugin
通过测试类创建JAR,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
我想添加源代码以使用maven-source-plugin
来测试JAR:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>attach-test-sources</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
结果,我得到了四个JAR文件:
<name>.jar
<name>-sources.jar
<name>-tests.jar
<name>-test-sources.jar
我的问题是我做错了什么,我不能为测试的类下载源代码,但可以为主要的类下载源代码?
致谢
答案 0 :(得分:1)
<name>-tests.jar
并非拼写错误,请参见Apache Maven JAR Plugin / jar:test-jar:
<classifier>
}用于test-jar
的分类器。 默认值为:tests
。