manually install jar dependency

How to manually install JAR dependency in local repository using maven

This tutorial will teach you how to manually install jar dependency using maven i.e., how to place third party JAR files in local repository that does not exist in any public repository like Maven Central. So that it will be correctly picked up by Apache Maven.

To install JAR in the local repository use the following command.

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

For example, let’s say you had added the following dependency in the pom.xml, but the command mvn clean install failed to install that dependency.

<dependency>
  <groupId>com.googlecode.cqengine</groupId>
  <artifactId>cqengine</artifactId>
  <version>3.0.0</version>
</dependency>

Then you need to manually install this JAR dependency using the following command

mvn install:install-file -DgroupId=com.googlecode.cqengine -DartifactId=cqengine \
     -Dversion=3.0.0 -Dfile=E:\Sneppets\cqengine-3.0.0.jar -Dpackaging=jar -DgeneratePom=true

Install JAR dependency manually

Run the following command, you should see the following message which shows that the JAR is installed in the local repository

> mvn install:install-file -DgroupId=com.googlecode.cqengine -DartifactId=cqen
gine -Dversion=3.0.0 -Dfile=E:\Sneppets\cqengine-3.0.0.jar -Dpackaging=jar -Dgen
eratePom=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom
---
[INFO] Installing E:\Sneppets\cqengine-3.0.0.jar to C:\Users\sneppets\.m2\repositor
y\com\googlecode\cqengine\cqengine.0.0\cqengine-3.0.0.jar
[INFO] Installing C:\Users\sneppets\AppData\Local\Temp\mvninstall257506539214871806
4.pom to C:\Users\sneppets\.m2\repository\com\googlecode\cqengine\cqengine.0.0\cq
engine-3.0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.169 s
[INFO] Finished at: 2019-05-17T21:42:25+05:30
[INFO] Final Memory: 8M/309M
[INFO] ------------------------------------------------------------------------

You can also verify whether the JAR is available in the following location

C:\Users\sneppets\.m2\repository\com\googlecode\cqengine\cqengine\3.0.0

manually install jar dependency

Further reading

References

guest
0 Comments
Inline Feedbacks
View all comments