Search code examples
mavenconfiguration-management

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


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.


Solution

  • 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