maven-jar-plugin with maven-source-plugin not working

1.7k Views Asked by At

I'm using maven-jar-plugin to create JAR with my test class as below:

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

I want to add source code to test JAR using maven-source-plugin like that:

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

As results I got four JAR files:

<name>.jar
<name>-sources.jar
<name>-tests.jar
<name>-test-sources.jar

My question is what I do wrong that I can't download sources for test's classes but can do that for main classes?

Regards

1

There are 1 best solutions below

0
On

<name>-tests.jar is not a misspelling, see Apache Maven JAR Plugin / jar:test-jar:

<classifier>   Classifier to used for test-jar. Default value is: tests.