Sunday, 16 February 2020

Add Local Jar files to a Maven Jar




 

We can add Local Jar files to the Maven Jar with the below steps

   
  • Put the dependency in a "file system repository" local to the project.
  • Declare that repository in the pom.xml as below
                       <repositories>
                             <repository>
                                 <id>somename</id>
                                 <url>file://${basedir}/lib</url>
                             </repository>
                       </repositories>

  • Then Just Declare the dependency as below
                       <dependency>
                              <groupId>inc.skt</groupId>
                              <artifactId>skt-localjar</artifactId>
                              <version>1.0</version>
                       </dependency>

  •  To Add the Jar to Maven Local Repository run the below command from the location where you have pom.xml
mvn install:install-file -Dfile=C:\Model.jar -DgroupId=inc.skt -DartifactId=skt-localjar -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true