Maven: Is it possible to upload a set of 3rd party

2020-03-31 08:14发布

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?

2条回答
【Aperson】
2楼-- · 2020-03-31 09:08

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>
查看更多
ら.Afraid
3楼-- · 2020-03-31 09:13

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.

查看更多
登录 后发表回答