Tuesday 4 March 2014

Manual Installation of 3rd party jars in Maven

Occasionally, while using Apache Maven, we may come across scenarios when we would have to manually install 3rd party dependency jars. This might occur when a certain dependency jar does not exist on your local repository or Maven Central. Let's discuss how to manually install such jars.

The first obvious step would be to download the 3rd party jar. For instance Kaptcha or Gin. Now our next job would be to install this jar into our local repository, so that Maven detects it. Open terminal and browse to your local Maven repository.

For installing the jar, we provide a goal to the maven-install-plugin. Use the goal install:install-file and pass parameters as shown in the below example :

mvn install:install-file -Dfile=path-to-3rd-party.jar -DgroupId=com.example-plugin.code -DartifactId=example-plugin-name -Dversion=version-of-the-jar -Dpackaging=jar

The Output would start with something like this. You'll see the Build Success message once the plugin is installed successfully.



The entire list of paramaters that can be passed to the goal install:install-file can be found here.

Note that once such 3rd party jars are installed, you may have to use the sha1 or md5 utility to create MD5 checksums of the jar and pom that got created within the repository. Refer my previous post on using the MD5 utility.

Also, correct me if am wrong, in older Maven 1 versions, once the plugin is installed, you had to manually edit the generated pom to include details like groupId, artifactId and version. However in Maven 2+ versions, the pom gets auto-populated with these details.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker