简体   繁体   中英

How do I include a 3rd party jar in maven?

I have OmnitureAPI.jar and I could not find it in mvn repo. Hence I though I will include it myself using the following command that I found online describing a similar issue that I am currently facing.

mvn install:install-file -Dfile=c:\kaptcha-{version}.jar -DgroupId=com.google.code -DartifactId=kaptcha -Dversion={version} -Dpackaging=jar

I have two questions: 1) Does the jar that I am including needs to following maven naming and packaging conventions such as the classes should be in src/main/java etc? 2) While executing above command what should I put in -DgroupId=xxxx and -DartifactId=xxx ?

Please guide

Here's the Guide to installing 3rd party jars.

If it's not a maven-built jar and there's no pom.xml, you'll need to specify these things yourself:

mvn install:install-file -Dfile=<path-to-your-jar> -DgroupId=<make-up-a-group-id> \
-DartifactId=<make-up-an-artifact-id> -Dversion=<specify-a-version> -Dpackaging=jar

The best way to do this is use the pom.xml file included in the jar, if it exists. I had to do this recently, and here's the command I used:

mvn install:install-file -Dfile=./elasticsearch-river-jdbc-0.90.3.1.jar

If it can't find the POM, you may need to point mvn at the POM manually:

mvn install:install-file -Dfile=elasticsearch-river-jdbc-0.90.3.1.jar -DpomFile=./META-INF/maven/org.xbib.elasticsearch.plugin/elasticsearch-river-jdbc/pom.xml

If there's no pom.xml in the jar, and no group id or artifact id exists, you can make up your own; but you need to then use the same parameters when you reference the JAR.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM