Installing third party jars in Maven

Posted by Jose Estudillo on December 23, 2014

Installing third party jars in Maven

Some companies don’t put their jars in Maven official repositories, so when working in a local environment is useful to have this jars available as any other.

	mvn install:install-file -Dfile=JAR_FILE_PATH -DgroupId=GROUP_ID -DartifactId=ARTIFACT_ID -Dversion=VERSION  -Dpackaging=jar

where:

  • JAR_FILE_PATH: path to the jar file to install
  • GROUP_ID: Id to identify a group that will contains the jars released by the same provider (i.e. org.springframework)
  • ARTIFACT_ID: Id to identify a single jar file (i.e. spring-core)
  • VERSION: version of the specific jar (i.e. 1.2.0)

to declare this new added jar in the pom.xml

<project>
  ...
  <dependencies>
    ...
    <dependency>
      <groupId>GROUP_ID</groupId>
      <artifactId>ARTIFACT_ID</artifactId>
      <version>VERSION</version>
    </dependency>
    ...
  </dependencies>
  ...
</project>