Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centralized local Maven repository for Team

Our team of developers uses Maven for building software. We have Maven local repository on our computers. 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. For example:

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

In this case Maven gets the newest library installed locally.

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.

Is there any better solution for this case?

How can I have centralized Maven local ?

like image 296
mariami Avatar asked Nov 06 '22 19:11

mariami


1 Answers

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. So you get the same results on every computer (unless you have SNAPSHOT versions which might differ).

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

like image 190
J Fabian Meier Avatar answered Nov 13 '22 04:11

J Fabian Meier