Sometimes you might need to package 3rd party JAR files in a way that allows you to incorporate them into a maven project easily. To do so, you need to put the JARs in a local repository to so that the can be picked up by Apache maven. You can achieve this by using the maven-install-plugin by running the following command:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \ -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
To illustrate this with an example, let us assume that we want to add the Algorithms Book library to your local repository. You need download first the algs4.jar to your machine (i.e. ~/Downloads). Once you have done so, you can run the following command to add this file to your local repository.
mvn install:install-file -Dfile=~/Downloads/algs4.jar -DgroupId=edu.princeton.cs \ -DartifactId=algs4 -Dversion=1.0 -Dpackaging=jar
Once you added the jar file to the local repository. You can use the following XML in your project’s pom.xml.
<dependency> <groupId>edu.princeton.cs</groupId> <artifactId>algs4</artifactId> <version>1.0</version> </dependency>