I have few jar files which I am not getting from any repositories.I have these jar files in WEB-INF\lib folder for src directory. Is there a way to add these as dependencies in POM without specifying the actual path of the jar files (relative path is fine..)?
You can define the dependencies as follows:
<dependency>
<groupId>my.group</groupId>
<artifactId>my.artifact</artifactId>
<version>a.b</version>
<scope>system</scope>
<systemPath>${basedir}/WEB-INF/lib/my.artifact.jar</systemPath>
</dependency>
Essentially you specify the scope as <system>
to indicate to maven not to look for this in a repository and <systemPath>
to indicate where it is. This would be an absolute path, but can take maven properties. Details here.
You would do this for each such jar that you have.
You should install these files in your local repository. Ideally, you have a shared repository installed on your local machine or on a remote server (Nexus, Artifactory, Archiva) and you deploy your jars to that repository.
To install a file locally, you can use the following command (taken from the Maven install plugin website):
mvn install:install-file -Dfile=your-artifact-1.0.jar \
[-DpomFile=your-pom.xml] \
[-Dsources=src.jar] \
[-Djavadoc=apidocs.jar] \
[-DgroupId=org.some.group] \
[-DartifactId=your-artifact] \
[-Dversion=1.0] \
[-Dpackaging=jar] \
[-Dclassifier=sources] \
[-DgeneratePom=true] \
[-DcreateChecksum=true]
In your pom, you can then reference those jars as regular dependencies. For more information on the Maven Install Plugin, take a look at their website.
Using Apache Maven Dependency Plugin
mvn dependency:copy-dependencies
and you will find target/dependencies
folder filled with all the dependencies, including transitive.mvn dependency:purge-local-repository
and try again.Using eclipse:
Click on Next to get the following wizard:
Select Maven Dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With