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]
 -DartifactId=[package-id] -Dpackaging=jar -Dversion=[version]
 -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
 -DgroupId=jboss.jboss-api -DartifactId=jboss-api-lib -Dpackaging=jar
 -Dversion=2.6.4 -DgeneratePom=true