Maven Source Plugin: Difference between revisions
Jump to navigation
Jump to search
(Created page with "!!!Generating the source jar {{{ <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-...") |
|||
(13 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=External= | |||
* https://maven.apache.org/plugins/maven-source-plugin/ | |||
=Internal= | |||
* [[Maven#Plugins|Maven]] | |||
=Generating the source jar= | |||
<pre> | |||
<build> | |||
<plugins> | <plugins> | ||
<plugin> | <plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | <groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | <artifactId>maven-source-plugin</artifactId> | ||
<version>${maven.source.version}</version> | |||
<executions> | <executions> | ||
<execution> | <execution> | ||
Line 18: | Line 27: | ||
</plugin> | </plugin> | ||
</plugins> | </plugins> | ||
</build> | |||
</pre> | |||
If the "maven-source-plugin" is active, maven install will also install the source jar. | If the "maven-source-plugin" is active, maven install will also install the source jar. | ||
<blockquote style="background-color: Gold; border: solid thin Goldenrod;"> | |||
:<br>'''Important''' Place the plugin in <tt><plugins></tt>, not in <tt><pluginManagement><plugins>...</plugins></pluginManagement></tt>, otherwise it will silently fail. For a project hierarchy, place the plugin at each level of the hierarchy where you want to publish sources.<br><br> | |||
</blockquote> | |||
=Installing the source artifact in the repository post factum= | |||
<pre> | <pre> | ||
mvn install:install-file -DgroupId=my.group -DartifactId=my-file -Dversion=1.0 \ | mvn install:install-file -DgroupId=my.group -DartifactId=my-file -Dversion=1.0 \ | ||
-Dpackaging=jar -Dclassifier=source -Dfile=./my-file-src.jar | -Dpackaging=jar -Dclassifier=source -Dfile=./my-file-src.jar | ||
</pre> | |||
=Running from Command Line= | |||
<pre> | |||
mvn source:jar | |||
</pre> | </pre> |
Latest revision as of 00:00, 27 February 2020
External
Internal
Generating the source jar
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>${maven.source.version}</version> <executions> <execution> <id>attach-sources</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
If the "maven-source-plugin" is active, maven install will also install the source jar.
Important Place the plugin in <plugins>, not in <pluginManagement><plugins>...</plugins></pluginManagement>, otherwise it will silently fail. For a project hierarchy, place the plugin at each level of the hierarchy where you want to publish sources.
Installing the source artifact in the repository post factum
mvn install:install-file -DgroupId=my.group -DartifactId=my-file -Dversion=1.0 \ -Dpackaging=jar -Dclassifier=source -Dfile=./my-file-src.jar
Running from Command Line
mvn source:jar