简体   繁体   English

团队的集中本地Maven存储库

[英]Centralized local Maven repository for Team

Our team of developers uses Maven for building software. 我们的开发团队使用Maven构建软件。 We have Maven local repository on our computers. 我们的计算机上有Maven本地存储库。 The problem is that sometimes builds made from two different developer differ, because the built packages include different version of included dependencies. 问题在于,有时由两个不同的开发人员构建的构建会有所不同,因为构建的包包含不同版本的包含依赖项。

This happens when version tag is not mentioned in POM.xml file for dependencies. 在POM.xml文件中未提及依赖项的版本标记时会发生这种情况。 For example: 例如:

<dependency>
            <groupId>mylib-group</groupId>
            <artifactId>mylib-artifact</artifactId>
</dependency>

In this case Maven gets the newest library installed locally. 在这种情况下,Maven获得了本地安装的最新库。

To avoid this problem We installed Maven on one computer (we call Build server) and all members of our team make build on that computer. 为了避免这个问题我们在一台计算机上安装了Maven(我们称之为Build服务器),我们团队的所有成员都在该计算机上构建。

Is there any better solution for this case? 对于这种情况有没有更好的解决方案?

How can I have centralized Maven local ? 我如何在本地集中Maven?

First of all: if you have a dependency like 首先:如果你有一个像依赖的依赖

<dependency>
    <groupId>mylib-group</groupId>
    <artifactId>mylib-artifact</artifactId>
</dependency>

Maven will not take the latest version, but the one defined in the <dependencyManagement> section. Maven 不会采用最新版本,而是<dependencyManagement>部分中定义的版本。 So you get the same results on every computer (unless you have SNAPSHOT versions which might differ). 因此,您可以在每台计算机上获得相同的结果(除非您有可能不同的SNAPSHOT版本)。

Having said that: Having a build server is generally a good idea for having a stable environment for builds. 话虽如此:拥有一个构建服务器通常是一个良好的想法,为构建提供稳定的环境。

Addendum: You can not share a Maven local repository. 附录:您无法共享Maven本地存储库。 This repository is not thread safe and running two builds at the same time on the same local repository can have strange effects (I speak from experience). 此存储库不是线程安全的,并且在同一本地存储库上同时运行两个构建可能会产生奇怪的影响(我从经验中说)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM