Maven dependency – Local jar file from an external third party to be installed into project repository
Some time back, I was working on an application that involved payments processing. I worked with a payments company called DataCash. They made available a jar file with their API. Now the app I was working on used Maven for dependency management. Usually, if one needs an API to be included for use in the app, one would just add it into the maven pom.xml file in an appropriate location in the dependencies or dependenciesManagement section. However, this api-jar was not something that was publicly acessible.
Sure, you could drop the jar into your localRepository while you work on it initially. But when you commit your code, the project repository still won’t have it. So others on your team would get a missing dependency error.
What you really need to do is to deploy the jar into your project repository. Here is what should work to do this -
mvn deploy:deploy-file -DgroupId=com.datacash -DartifactId=datacash-api -Dversion=2.1.1 -Dpackaging=jar -Dfile=DataCash-Java-2.1.1.jar -Durl=http://
You can use any appropriate groupId and artifactId. Tools like Artifactory also have a web UI to install jars.
Do leave a comment if this or something else that you tried worked for you!
Tags: Java, Maven