Skip to content
Advertisement

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.

Question:

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.

Advertisement

Answer

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

JavaScript

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

Or from command line:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement