Sharing the same settings.xml maven configuration for the whole team

Viewed 486

We have a very big maven configuration with very many repositories, plugin repositories, and various other things.

We always end up having to manually copy/paste the same file to other team members, and then replace the username and password.

I was curious if anyone is aware of an automated solution for sharing the settings.xml file ?

Something that will pull the configuration or part of the configuration from git ?

If I had to write it myself I would probably use a script and git, to pull changes, do replacements, and replace the current settings file.

But it's better to see if someone has already made this.

We also have a different proxy username and password for each user. We use both nexus, and also a proxy.

2 Answers

Tomtit is good with that type of tasks, just include this small helper into your scm:

.tom/mvn-settings.pl6

#!perl6

my $user = prompt "username ";
my $password = prompt "password ";

directory '/tmp/mvn';

# load settings template from other repository

git-scm 'https://scm/repo/mvn-files', %( to => '/tmp/mvn' );

template-create 'settings.xml', %(
  source => ( slurp '/tmp/mvn/settings.tmpl' ),
  mode => '644',
  variables => %(
    user => $user,
    password => $password
  ),
);

The run it:

tom mvn-settings

We use a Nexus, which proxies all the desired repositories. This means that the repositories and plugin repositories section in the settings.xml have only one entry each (pointing to the public group).

Furthermore, adding/changing repositories can be done by the Nexus admin, and is propagated automatically to everyone (about 140 developers) using the standard settings.xml.

You furthermore gain the caching advantage because the artifacts are downloaded only once from the internet and cached by Nexus, which can speed up your builds.

Related