There are situations where you want to add your own .jar library as maven dependency. Also there are third party libraries which are not available in the central maven repository. In a situation like that you can add that .jar file in your local repository and use as a maven dependency.
Here is how to add a .jar file as a local maven dependency.
Issue following command (edit the parameters according to your file). Issue the command in single line. I have separated it to lines for easy understanding.
mvn install:install-file -Dfile=/home/me/sample-1.0.jar -DgroupId=com.mycuteblog.code -DartifactId=sample -Dversion=1.0 -Dpackaging=jar
Then you can add the maven dependency in the .pom file as follows,
<dependency> <groupId>com.mycuteblog.code</groupId> <artifactId>sample</artifactId> <version>1.0</version> </dependency>
Once you build the project sample.jar will be available to use in your project.
If you distribute the code make sure to add this to a common repository that all can access. Else other developers will get ‘Could not resolve dependencies’ error.