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.