Saturday, 17 January 2015

Maven Tip: Adding a Custom Jar to your Maven Project

Sometimes you come across a jar which you want to include in your Maven project but is not in Maven Central.  This happened to me recently with a great web scraping library called jaunt which I wanted to include in my Maven java project.

One way (maybe the best way) is to add the jar to you local Maven repository which you can do with this command.


mvn install:install-file -Dfile=jaunt0.9.9.4.jar -DgroupId=com.jaunt.code -DartifactId=jaunt -Dversion=0.9.9.4 -Dpackaging=jar

Then add to your dependencies in Maven as below:

 <dependency>
            <groupId>com.jaunt.code</groupId>
            <artifactId>jaunt</artifactId>
            <version>0.9.9.4</version>
  </dependency>

The issue with this methodology is if you want to share your project with people who don't have access to you local Maven repository.  For example, if you want to put your project on Git for general release.

Of course you could always check in the actual source but that's not always possible or necessarily desirable. If you have any good solutions please leave in the comments.   

3 comments:

  1. Real PCNSE Dumps Practice Exam Questions from marks4sure.com.

    ReplyDelete
  2. 77%OFF Coach Outlet Store-Coach Bags Clearance Sale,100% Popular
    New & Popular Ray Ban Sunglasses Outlet Store Online,2020-2021 Stylish
    Clearance Coach Store | 80%OFF Coach Bags Outlet On Sale Online
    Share Best Best Adidas Yeezys Store|100% New & Real Yeezy Boost For Sale
    2020 Nike Air For 1 Shoes Outlet For Men & Women, 68-85%OFF Cheap Sale
    Official Michael Kors Outlet Store Online,100% Cheap MK Bags Sale
    61-82%OFF Air Jordan Shoe Stores|Cheap Jordans Releases,Hot Sale

    ReplyDelete