0

I want to attach -sources jar alongside my created package. To do that I want to use the maven-source-plugin. However, when I run mvn clean package, only the "compiled jar" is created, the sources jar is not present.

I am able to create the sources jar manually by running mvn source:jar though.¨

The build configuration section looks like this: (the variables/placeholders are replaced before running the pom).

<build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.5.1</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <classifier>${classifier}</classifier>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>

        <resources>
            <resource>
                <directory>${project.basedir}</directory>
                <includes>
                    <include>*.proto</include>
                </includes>
            </resource>
        </resources>

    </build>

Why is the plugin not run automatically as part of the package phase? Adding that phase explicitly does not help, the documentation states it is bound to it by default. I have declared dependencies on the plugins as well.

Martin Melka
  • 7,177
  • 16
  • 79
  • 138
  • 1
    The same question was asked today http://stackoverflow.com/q/37068724/1743880. You're declaring your plugin inside ``. – Tunaki May 06 '16 at 11:56
  • 1
    You are right. From the maven documentation I thought that is a "superset" of . I was wrong. Thanks – Martin Melka May 06 '16 at 11:58

0 Answers0