Add a jar to maven local repository

Below is how to do it

mvn install:install-file
  -Dfile=<path-to-file>
  -DgroupId=<group-id>
  -DartifactId=<artifact-id>
  -Dversion=<version>
  -Dpackaging=<packaging>
  -DgeneratePom=true

Where: <path-to-file>  the path to the file to load
       <group-id>      the group that the file should be registered under
       <artifact-id>   the artifact name for the file
       <version>       the version of the file
       <packaging>     the packaging of the file e.g. jar

For example, I want to add simplejpa to my maven local repository, here’s the command I issued:

mvn install:install-file
-Dfile=~/Programming/api/simplejpa-1.5.jar
-DgroupId=com.spaceprogram
-DartifactId=simplejpa
-Dversion=1.5
-Dpackaging=jar
-DgeneratePom=true

This will add the simplejpa jar into the local Maven2 repository under groupId com.spaceprogram and artifactId simplejpa. pom.xml file needs to be edited to add this dependency.

Reference links: http://maven.apache.org/general.html#importing-jars http://jeff.langcode.com/archives/27

This entry was posted in maven and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s