1

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,

  1. added the jars in my project path(\src\lib)
  2. 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

Community
  • 1
  • 1
sasikals26
  • 835
  • 2
  • 18
  • 41

3 Answers3

5

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/)

Prim
  • 2,880
  • 2
  • 15
  • 29
4

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.

Puce
  • 37,247
  • 13
  • 80
  • 152
  • Thanks Puce, but unfortunately I can not do that since it is not an open source SDK jars – sasikals26 Jan 11 '16 at 13:02
  • 1
    @sasikals26 Maven Repository Managers such as Nexus are usually installed on your own servers and thus they should be perfectly fine to host non-OS JARs. – Puce Jan 11 '16 at 13:05
  • Thanks again , but can you let me know where these jars get uploaded.. in central repository ?? – sasikals26 Jan 11 '16 at 13:22
  • 1
    No. They are installed on your own server (or wherever you install Nexus). – stevecross Jan 11 '16 at 13:43
1

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.

kctang
  • 10,894
  • 8
  • 44
  • 63