The official "Maven Way" of dependency management is to use Maven Central and local repository specified in the
settings.xml file (which usually points to
$HOME/.m2/repository. While it works great for projects that rely on a large number of open source libraries and satisfies 95% of dependency management needs in those projects, there is that 5% of the time when a jar is
not sourced from a Maven project. One example is a jar using JNI so is only available for certain OS platforms. How do we integrate this jar into Maven dependency management? If you search the web for hints, you may be led to believe that you either have to bend to the Maven Way or to use the systemPath. But the Maven Way will force you to maintain a local repository for a trival library. The systemPath on the other hand does not work naturally with packaging. Developers will most likely ask "Can I check in this library to my (your_favorite_VCS) with my project and still have Maven use it in a way just like any other dependency?" The answer is YES. Just follow the steps below:
1. Create a directory under your project, say "lib".
2. Use Maven to install your jar to the lib directory.
mvn install:install-file -Dfile=path_to_mylib.jar -DgroupId=com.mylib -DartifactId=mylib -Dversion=1.0 -Dpackaging=jar
-DlocalRepositoryPath=path_to_my_project/lib
3. Setup your POM like this.
<repositories>
<repository>
<!-- DO NOT set id to "local" because it is reserved by Maven -->
<id>lib</id>
<url>file://${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.mylib</groupId>
<artifactId>mylib</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
Now you can check in/out mylib.jar just like any other file in your project and Maven will manage the dependency on mylib.jar just like any other dependency artifact. Perfect harmony. :-)
Worked like a charm.
ReplyDeleteGreat tip!
Hi,
ReplyDeleteThanks for this post. It already helped me several times.
This comment has been removed by the author.
ReplyDeleteThanks.. worked great...
ReplyDeleteHi,
ReplyDeleteCan you please help me showing entries for my jars say aaa.jar, bbb.jar and ccc.jar , ddd.jar and eee.jar in pom.xml. All these jars are present in tomcat/myproject/lib/ folder.
Thanks,
Kavitha
Thanks, This really helped me.
ReplyDeleteWorked wonderfully. Thank you.
ReplyDeleteWow Such a Nice Idea,Great Thanks Once again
ReplyDeleteThanks from 2020 !
ReplyDeleteSimple and clear. Keep sharing more and more DevOps Online Training
ReplyDeleteDevOps Online Training India
DevOps Online Training hyderabad
Nice Post. Keep sharing more and more Appian BPM training
ReplyDeletearcsight online training
arcsight training
Build and Release online training
Build and Release training
Dell Bhoomi online training
Dell Bhoomi training
Dot Net online training
Dot Net training
ETL Testing online training
ETL Testing training
Hadoop online training
Hadoop training
Tibco online training
Tibco training
That is nice article from you, this is informative stuff. Hope more articles from you . I also want to share some information about bw Training
ReplyDeleteazure networking
ReplyDeletearm templates
azure notification hub
azure bastion host
app power bi
kubernetes dashboard
terraform cheat sheet
aws vpc
ReplyDeleteazure devops certification
azure load balancer
azure databricks
kubernetes dashboard
openshift certification
ReplyDeleteazure data engineer certification
aws solution architect training
azure solution architect certification
cloudkeeda
ReplyDeletecloudkeeda
cloudkeeda
cloudkeeda
cloudkeeda
cloudkeeda
cloudkeeda
what is azure
azure free account
az 900 study guide
ReplyDeleteai 900 study guide
dp 900 study guide
sc 900 study guide
pl 300 study guide
az 204 study guide
az 500 study guide
dp 300 study guide
dp 100 study guide
dp 203 study guide
az 104 study guide
az 600 study guide
Lovely post..! I got well knowledge of this blog. Thank you!
ReplyDeleteVirginia Family Law Attorneys
Local Family Lawyers
supportfly
ReplyDeleteleasepacket
Cloud storage server
ReplyDeleteGet Storage Server with high data capacity to store all your data. Customize data storage server at best price with 24/7 Server Support.
Elevate your email marketing with our expert Mailwizz services. Unlock efficient campaigns and superior deliverability today.
ReplyDelete