Maven: How to use local lib

Posted on

Sometime ago I saw me before a situation that I’ve never had passing before. I needed use my local lib on Java maven project.



To do that I followed the steps:

Step One: Put in my local library into maven repository

mvn install:install-file -Dfile=home/victor/dev/Example.jar -DgroupId=br.com.example -DartifactId=Example -Dversion=1.0.0 -Dpackaging=jar
Enter fullscreen mode

Exit fullscreen mode

Step Two: Install maven dependencies

mvn clean install
Enter fullscreen mode

Exit fullscreen mode

Step Three: Use the library in the project

Add the pendency in the pom.xml file like that:

<dependencies>
  ...
  <dependency>
    <groupId>br.com.example</groupId>
    <artifactId>Example</artifactId>
    <version>1.0.0</version>
  </dependency>
  ...
</dependencies>
Enter fullscreen mode

Exit fullscreen mode

That’s it!

I hope this helps you.

Leave a Reply

Your email address will not be published.