Thursday, June 16, 2016

How to add a Custom JAR to a Maven Project

I know that this is old for many but it is new for me and so I am posting it. :-)

When working with custom JARs and Maven you will need to install them into Maven to reference them from the Project Object Model (POM) file.
Here is what you do at the command line:
 mvn install:install-file -Dfile="C:\Java Projects\MyProject\Marks-1.0.0-SNAPSHOT.jar" -DgroupId=fyi.m2.java -DartifactId=Marks -Dversion=1.0.0 -Dpackaging=jar -e  


Within the POM here is the dependency setting:

1:  <dependency>  
2:     <groupId>fyi.m2.java</groupId><!-- DgroupId -->  
3:     <artifactId>Marks</artifactId><!-- DartifactId -->  
4:     <version>1.0.0</version><!-- Dversion --> 
5:   </dependency>  

Now the JAR is included in the Maven Dependencies.

No comments: