Setting the developerConnection for the Maven Release Plugin from the command line

3k Views Asked by At

I am currently trying to configure the Maven Release Plugin for our build server.

For that I am trying to set the <scm><developerConnection> through the command line. I read that

project.scm.developerConnection

is the command line property(https://maven.apache.org/guides/mini/guide-releasing.html). I tried to set it but it seems to have no effect. When I start the build, it uses a constructed URL (parent pom url + artifactId) that fails.

I have looked at the source code of the plugin but did not find the command line property mentioned above.

Can anybody shed light on this?

2

There are 2 best solutions below

5
user944849 On

When you run mvn release:prepare, Maven forks. The arguments supplied on the command line are passed to the initial Maven call (the one you/build server ran) not to the fork.

To pass args to the release plugin, supply the arguments as shown:

mvn release:prepare -Darguments="-Dproject.scm.developerConnection=..." ...

Depending on what I'm trying to do, sometimes I've had to specify in two places, so both original and forked processes get the args:

mvn release:prepare -DsomeArg=val -Darguments="-DsomeArg=val" ...

The first example in the release plugin FAQ shows an example of where the latter is useful.

---- Update ----

I found the property in the maven-scm-plugin code.

SCM ValidateMojo.scmDeveloperConnection

Maybe project.scm.developerConnection is read-only? Try setting scmDeveloperConnection instead, as it's listed as the property name.

0
gsim On

It looks that you cannot pass this property directly from command line. See:

https://issues.apache.org/jira/browse/MRELEASE-707

But you should get it working by specifying it through a custom property in your pom.xml:

<properties>
    <my.developer.connection />
</properties>

<scm>
    <developerConnection>${my.developer.connection}</developerConnection>
    <tag>HEAD</tag>
</scm>

And running maven with, for example:

-Dmy.developer.connection=scm:git:ssh://user@host/repo.git

I use this approach to keep my pom.xml clean when generating a public release that should not contain information about my company's internals.