Sometimes the maven repositories don’t have all the libraries we need and, we need to add a concrete library to our repository. Usually, this is because there is a problem with its license, something similar or only because it is a library that we have built for our own projects. In both cases, the steps to add the library to our own repository are quite simple.
For this example, we are going to use the library example-1.0-jar and the information about this library is going to be:
- groupId: org.example
- artifactId: example
- version: 1.0
To add this library to our repository, we only need to execute a simple command:
mvn install:install-file -Dfile=<libraryName> -DgroupId=<groupId> -DartifactId=<artifactId> -Dversion=<version> -Dpackaging=jar
With our example data, the command should look like this:
mvn install:install-file -Dfile=example-1.0.jar -DgroupId=org.example -DartifactId=example -Dversion=1.0 -Dpackaging=jar
Finally, we only need to add our new dependency in our maven file, and that’s all.
<dependency>
<groupId>org.example</groupId>
<artifactId>example</artifactId>
<version>1.0</version>
</dependency>
See you.