Lib directory as repository

With simple trick you can create project's private repository in a lib directory in a Maven project. I use this way when JAR libraries cannot be found in public repositories, a example is the proprietary Oracle JDBC driver.

Firstly add new repository declaration to your project's pom.xml:

      <name>Repository in project's lib dir</name>

Next, to install jar in the lib repo, invoke line below under project directory. Remember to fill in -Durl parameter properly.

mvn deploy:deploy-file -Durl=file:///c:/FULL_PATH_HERE/lib \
   -DrepositoryId=project_lib -Dfile=ojdbc14.jar \  -DartifactId=ojdbc14 \
   -Dversion= -Dpackaging=jar

Make sure that apropriate structure was created under lib directory. Finnaly you can add following dependency to project's pom.xml:


Generally for big projects it is recommended to create a shared repository for development teams, however above approach is more consistent especially when project is archived and you are not sure about durability of your shared repo.

The system scope way

If you need JAR only for build phase then there is a simpler way of adding JAR from custom directory as dependency: the system scope. It is similar to provided scope because dependencies are added to build phase classpath. In such case JARs won't be incorporated automatically to WARs, EARs etc, as it happens with compile scope. To overcome this limit I suggest using lib as repository way. Below is the example usage of system scope with lib directory.