Skip to content

How to upload sources to local Maven repository

Suppose I have a Maven 2 Java project on my local machine. I build the project .jar file and push it to my local Maven repo, using mvn install.


How can I force Maven to also push the project sources jar to the local repo?

This is useful if I’ll use the above mentioned project as dependency while developing a new project, and can use the mvn eclipse:eclipse -DdownloadSources feature.



This snippet automatically installs / deploys a source jar from any install / deploy:

        <version>[whatever version is current]</version>

Use this link to check for the current version of the maven-source-plugin

Or from command line:

mvn clean source:jar install
6 People found this is helpful