Maven: How to include jars, which are not available in reps into a J2EE project? Maven: How to include jars, which are not available in reps into a J2EE project? java java

Maven: How to include jars, which are not available in reps into a J2EE project?


For people wanting a quick solution to this problem:

<dependency>  <groupId>LIB_NAME</groupId>  <artifactId>LIB_NAME</artifactId>  <version>1.0.0</version>  <scope>system</scope>  <systemPath>${basedir}/WebContent/WEB-INF/lib/YOUR_LIB.jar</systemPath></dependency>

just give your library a unique groupID and artifact name and point to where it is in the file system. You are good to go.

Of course this is a dirty quick fix that will ONLY work on your machine and if you don't change the path to the libs. But some times, that's all you want, to run and do a few tests.

EDIT: just re-red the question and realised the user was already using my solution as a temporary fix. I'll leave my answer as a quick help for others that come to this question. If anyone disagrees with this please leave me a comment. :)


As you've said you don't want to set up your own repository, perhaps this will help.

You can use the install-file goal of the maven-install-plugin to install a file to the local repository. If you create a script with a Maven invocation for each file and keep it alongside the jars, you (and anyone else with access) can easily install the jars (and associated pom files) to their local repository.

For example:

mvn install:install-file -Dfile=/usr/jars/foo.jar -DpomFile=/usr/jars/foo.pommvn install:install-file -Dfile=/usr/jars/bar.jar -DpomFile=/usr/jars/bar.pom

or just

mvn install:install-file -Dfile=ojdbc14.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0 -Dpackaging=jar

You can then reference the dependencies as normal in your project.

However your best bet is still to set up an internal remote repository and I'd recommend using Nexus myself. It can run on your development box if needed, and the overhead is minimal.


Create a repository folder under your project. Let's take

${project.basedir}/src/main/resources/repo

Then, install your custom jar to this repo:

mvn install:install-file -Dfile=[FILE_PATH] \-DgroupId=[GROUP] -DartifactId=[ARTIFACT] -Dversion=[VERS] \ -Dpackaging=jar -DlocalRepositoryPath=[REPO_DIR]

Lastly, add the following repo and dependency definitions to the projects pom.xml:

<repositories>    <repository>        <id>project-repo</id>        <url>file://${project.basedir}/src/main/resources/repo</url>    </repository></repositories><dependencies>        <dependency>        <groupId>[GROUP]</groupId>        <artifactId>[ARTIFACT]</artifactId>        <version>[VERS]</version>    </dependency></dependencies>