Sometimes there is a dependency not available at a remote repository and one is too lazy to set up a local maven repository – that’s when one adds a directory in the project structure and wants maven to find dependencies there.
-
Create a directory called “lib” in the project root
-
Add the following markup to the pom.xml inside the <repositories>-Tag (create if it does not exist):
<repository> <id>lib</id> <name>lib</name> <releases> <enabled>true</enabled> <checksumPolicy>ignore</checksumPolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> <url>file://${project.basedir}/lib</url> </repository>
-
Assuming you’ve got a jar file with artifactId=mylibrary, groupId=com.hascode.plugin and a version=1.0.0 you should first rename your jar file to artifactId-version.jar – in the given example this would be mylibrary-1.0.0.jar
-
In the next step you should create a specific directory structure in your lib folder : Create a sub directory for each part of your groupId, then inside a directory named after the artifactId and inside of this one a directory named after the version. Put the jar in this last directory!
mkdir -p com/hascode/plugin/mylibrary/1.0.0
lib `-- com `-- hascode `-- plugin `-- mylibrary `-- 1.0.0 `-- mylibrary-1.0.0.jar
-
You should now be able to build your project with the bundled dependency .. if you’re using the Maven Eclipse Plugin a refresh of the Maven configuration might be needed…