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://yourteamdevserver:8081/artifactory/libs-snapshots -DrepositoryId=snapshots

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: ,
This entry was posted on Saturday, January 7th, 2012 at 7:20 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

One Response to “Maven dependency – Local jar file from an external third party to be installed into project repository”

  1. Dhruv

    I remember I did it once with the “Manually Install Artifacts” option in Netbeans. Don’t know if it did the same thing in the background.