Maven – Install a POM-less JAR

by Michael Scepaniak on January 11, 2009 in software development

At some point while using Maven, you’ll most likely come to a point where you need to install a POM-less artifact (probably a JAR) into your local Maven repository. This could happen for a number of reasons:

  • The JAR has never been published to a public Maven repository. This could be the case with a small, niche library.
  • You need to compile against JAR’s included in your runtime environment, which might be closed-source (e.g., WebSphere).
  • You might have some third-party JAR’s which you know work and are Maven-accessible, but you’re having difficulty determining their versions.

To install, run the following command (I think against any arbitrary pom.xml file):

mvn install:install-file -Dfile=[path/to/jar] -DgroupId=[group.id] n
 -DartifactId=[package-id] -Dpackaging=jar -Dversion=[version] n
 -DgeneratePom=true

So, for example, at one point in recent history, I needed to compile against some internal JBoss JAR’s. This is the command I used to install one of the JAR’s into my local Maven repository:

mvn install:install-file -Dfile=jboss-api-lib.jar n
 -DgroupId=jboss.jboss-api -DartifactId=jboss-api-lib -Dpackaging=jar n
 -Dversion=2.6.4 -DgeneratePom=true
Mike
Want to be notified when new articles are posted?
Enter your email address:

{ 0 comments… add one now }

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed

Previous post:

Next post:

Member of The Internet Defense League