Use server id to reference connection credentials in Maven plugin

Description

Instead of both properties username and password, you could reference connection credentials using the server tag details of settings.xml for not disclosing login & password in the POM file.

http://maven.apache.org/settings.html#Servers

A snippet to get authentication info in Maven:

/**

  • The Maven Wagon manager to use when obtaining server authentication details.

  • @component role="org.apache.maven.artifact.manager.WagonManager"

  • @required

  • @readonly
    */
    private WagonManager wagonManager;

/**

  • The server id in settings.xml to use when authenticating with.

  • @parameter expression="${liquibase.server}"
    */
    private String server;

...

// obtain authenication details for specified server from wagon
AuthenticationInfo info = wagonManager.getAuthenticationInfo( server );
if ( info == null ) {
throw new MojoExecutionException("server id not found");
}

// derive username
userName = info.getUserName();

// derive password
password = info.getPassword();

Hope that helps.

Environment

None

Activity

Show:
Nathan Voxland
December 14, 2010, 5:37 PM

Thanks

Alexandre Garino
December 17, 2010, 1:05 AM
Edited

Works like a charm with r1885. Thanks.

Could you apply the patch to the LiquibaseDatabaseDiff Mojo (referenceServer property) as well?

Nathan Voxland
December 17, 2010, 6:39 PM

Applied it to referenceServer

Alexandre Garino
December 17, 2010, 9:28 PM

Maven Plugin build against r1891. Tested successfully both liquibase.server and liquibase.referenceServer properties.

Nathan Voxland
December 17, 2010, 9:50 PM

Good, thanks

Reporter

Alexandre Garino

Fix versions

Affects versions

Priority

Major
Configure