Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a jar, source and Javadoc to the local Maven repository?

Tags:

maven

I'm wanting to add the latest version of JGoodies Forms (1.5.0) as a dependency, but I can't find anything newer than 1.0.5 in the main repository, so if I understand correctly, the next best thing I can do is add it to my local repository.

When I download it from the website, I get a ZIP file that contains the javadoc files, the source code and the jar (with just class files in it).

What is the procedure for adding this to my local Maven repository in such a way that Eclipse will be able to see the source and Javadoc? (I've only just started using Maven)

like image 905
Paul Walker Avatar asked Feb 21 '12 22:02

Paul Walker


People also ask

What is the command to install jar in Maven local repository?

In this case you can perform mvn initialize and jar will be installed in local maven repo. Now this jar is available during any maven step on this machine (do not forget to include this dependency as any other maven dependency in pom with <dependency></dependency> tag).


1 Answers

Update: Even though this is the accepted answer, please check the answer of Emmanuel Bourg below - his answer is probably what you would like to do, especially if you're having a snapshot version.


You can use the maven deploy plugin for that. It has a goal for deploying a single file to any repository. For the jar itself:

mvn deploy:deploy-file \     -DgroupId=com.yourname.jgoodies \     -DartifactId=jgoodies-forms \     -Dversion=1.50 \     -Dfile=/path/to/jgoodies-1.50.jar \     -Dpackaging=jar \     -Durl=file://path/to/your/local/repository  

For the sources:

mvn deploy:deploy-file \     -DgroupId=com.yourname.jgoodies \     -DartifactId=jgoodies-forms \     -Dversion=1.50 \     -Dfile=/path/to/jgoodies-sources.jar \     -Dpackaging=jar \     -Durl=file://path/to/your/local/repository \     -Dclassifier=sources 

For the javadoc:

mvn deploy:deploy-file \     -DgroupId=com.yourname.jgoodies \     -DartifactId=jgoodies-forms \     -Dversion=1.50 \     -Dfile=/path/to/jgoodies-javadoc.jar \     -Dpackaging=jar \     -Durl=file://path/to/your/local/repository \     -Dclassifier=javadoc 

Note that this will generate a standard POM, so you won't have the dependencies of JGoodies (if any) pulled automatically but have to specify them manually in your project.

like image 166
Jan Thomä Avatar answered Oct 09 '22 16:10

Jan Thomä