带有maven-source-plugin的maven-jar-plugin不起作用

时间:2018-11-07 15:18:19

标签: java maven maven-plugin maven-jar-plugin maven-source-plugin

我正在使用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

我的问题是我做错了什么,我不能为测试的类下载源代码,但可以为主要的类下载源代码?

致谢

1 个答案:

答案 0 :(得分:1)

<name>-tests.jar并非拼写错误,请参见Apache Maven JAR Plugin / jar:test-jar

  

<classifier>}用于test-jar的分类器。 默认值为: tests