Reputation: 865
I need to add some 15 jars in my maven project , and it is not available in both remote and central repository.
however, i have achieved it as below,
changed the pom as below,
<dependency>
<groupId>XXX</groupId>
<artifactId>YYY</artifactId>
<scope>system</scope>
<version>8.1</version>
<systemPath>${basedir}\src\lib\YYY.jar</systemPath>
</dependency>
My question:
Do i need to repeat it for all the 15 jars separatly as the above or we have any other way to bind these jars and make it as one dependency path?
The same thing discussed here Maven: System dependency pointing to multiple jars . but i wonder if i could get anything better/new ideas , since it is 5 years old discussion
Maven version: 3.3.9
Upvotes: 1
Views: 816
Reputation: 2968
I think you should never use systemPath
Instead, consider installing the jars into your local repository like explained here: https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
Maven let you add a library in your repository by calling manually:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
Doing that, your jars will be installed in your .m2 repository and will be available as other dependencies in your module
EDIT: We can add that when working with teamates, we usually use our own repository manager like Nexus (http://www.sonatype.org/nexus/) or Artifactory (https://www.jfrog.com/open-source/)
Upvotes: 5
Reputation: 11202
To deal with them as system scope, you will need to add each jar as a separate dependency.
You can specify as "single" jar if you pre-process and combine the jars (as a single jar) and give them another Maven GAV coordinates like "XXX:MY-SUPER-JAR:1.0". Note: I am NOT recommending this because it is a BAD practice.
As indicated by Prim's answer, system scopes should be avoided. Just setup a local repository.
Upvotes: 1
Reputation: 38132
I recommend to use a Maven Repository Manager such as Nexus (recommended for several reasons anyway) and host your 3rd-party libs there instead of some VCS.
Once you've uploaded the JARs you can reference them as normal dependencies.
Upvotes: 4