Maven: Is it possible to upload a set of 3rd party jars to repository, which can then be referenced as a single dependency?

StackOverflow https://stackoverflow.com/questions/23661856

  •  22-07-2023
  •  | 
  •  

سؤال

We are using an internal Nexus Repository for third party jars which are dependencies in our applications.

I am starting a new project, and have a set of 4 third party jar files which I want to upload to Nexus, and then reference, ideally, as a single dependency (i.e. artifactId/version) from my project pom.xml.

These jars are always given together, never versioned separately, so having a separate artifactId/version combination for each jar is not useful. Is it possible to upload all the jars into a single artifact/version folder in Nexus, and then to reference them as a single dependency in my Maven project?

هل كانت مفيدة؟

المحلول

As you refer to in your comment, you can create a pom file of your own that depends on the four jars you talk about. Then, release this to your local nexus. Once this is done, you can depend on it as a pom dependency, which will bring in the four libraries you want.

نصائح أخرى

I would use a custom property in the pom file to hold the version number, so that you can change the version once for all the dependencies. For example:

<properties>
    <spring.version>3.1.2.RELEASE</spring.version>
</properties>

<dependencies>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>

</dependencies>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top