Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add third-party jars into local Maven repository? [duplicate]

Tags:

java

maven

jar

I have a library consisting of 4 jars:

matlabcontrol-4.1.0.jar
matlabcontrol-4.1.0-javadoc.jar
matlabcontrol-4.1.0-sources.jar
matlabcontrol-demo-4.1.0.jar

How do I add them to the local repository so that Maven knows where sources are and where javadoc is?

Documentation here http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html is very brief and does not answer this question.

like image 913
Suzan Cioc Avatar asked Sep 27 '13 11:09

Suzan Cioc


2 Answers

The documentation clearly mentioned the way. Think your matlabcontrol-4.1.0.jar in C:> location. So move your cmd on C:> location and run following command.

mvn install:install-file -Dfile=matlabcontrol-4.1.0.jar -DgroupId=org.matlabcontrol \
    -DartifactId=matlabcontrol -Dversion=4.1.0 -Dpackaging=jar

If you do that, you can access your jar file with dependency, like:

 <dependency>
        <groupId>org.matlabcontrol</groupId>
        <artifactId>matlabcontrol</artifactId>
        <version>4.1.0</version>
 </dependency>
like image 71
Masudul Avatar answered Sep 24 '22 06:09

Masudul


Classifiers can also be specified at the command-line. See http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html#classifier.

Javadoc and sources are just artifacts with a classifier of the same pom.

For example:

Install the main artifact

mvn install:install-file -Dfile=matlabcontrol-4.1.0.jar 
   -DgroupId=matlab -DartifactId=matlab -Dversion=4.1.0

Install the javadoc using the classifier javadoc:

 mvn install:install-file -Dfile=matlabcontrol-4.1.0.jar 
   -DgroupId=matlab -DartifactId=matlab -Dversion=4.1.0 -Dclassifier=javadoc
like image 20
René Link Avatar answered Sep 23 '22 06:09

René Link