Adding external jars to the local maven repository

Reading Time: < 1 minute

At work I faced a situation that I had to add external jar libraries into my maven project, since most of required Java packages offered by Maven the automation, I have come across with the situation that Business objects external jars needed to be imported into the project. So I have done a small research regarding the issue, here is the outcome. First of all keep all he required in an easy location. I put the files in a folder called “libs” located right underneath C root drive the command below will do the magic

C:\workspace\CMC_REPORTING>mvn install:install-file -Dfile={FILELOCATION} -DgroupId={GROUP/DOMAINNAME} -DartifactId={FILENAME} -Dversion={VERSION} -Dpackagi
ng=jar

This command is going to add the required file to your local maven repo and you will get to use it, sample output after you carry out this command is:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\lib>mvn install:install-file -Dfile=fedmaster.jar -DgroupId=com.sap -Dartifac
tId=fedmaster -Dversion=1.0 -Dpackaging=jar
[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 C:\lib\fedmaster.jar to C:\Users\akn522a\.m2\repository\com\sa
p\fedmaster\1.0\fedmaster-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.365s
[INFO] Finished at: Mon Jan 20 09:21:16 EET 2014
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
C:\lib>

After the screen the necessary .jar file has been successfully imported into our maven local repo. There is one point left needs to be done, adding the imported jar in our pom.xml file. As usual add the line to your pom.xml

<dependency>
		<groupId>com.sap</groupId>
		<artifactId>fedmaster</artifactId>
		<version>1.0</version>
</dependency>

This is all now deploy your project to your application server and give it a shot