0
votes

I'm trying to create a release with the Maven Release Plugin, and it seems as if the tagBase setting is being completely ignored.

Here's what my pom looks like:

...
<scm>
    <developerConnection>scm:svn:http://svn.server/svn/repos/.../project/trunk</developerConnection>
</scm>
...
<build>
    ...
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <tagBase>http://svn.server/svn/repos/.../project/branches</tagBase>
            </configuration>
        </plugin>
    </plugins>
</build>
...

And here's the mvn release command I'm running:

mvn release:prepare

I initially tried this with the -DdryRun=true option, and noticed that the pom.xml.tag file that got generated by the dry run was referencing the .../project/tags/ directory instead of the .../projects/branches/ directory specified in the tagBase. I tried this without the dry run, and the results were the same. The release was created in the tags directory in my SVN repository instead of in the branches directory per the tagBase setting in the pom.

Why is tagBase being ignored? How can I get the maven release plugin to create the release under .../project/branches/ instead of .../project/tags/?

Edit - Adding Some Additional Information:

I'm using version 2.5.3 of maven-release-plugin and Maven version 3.3.9.

After running the mvn release:prepare -DdryRun=true command, here's what the generated release.properties and pom.xml.tag files look like:

release.properties:

#release configuration
#Thu Aug 25 09:07:24 EDT 2016
scm.tagNameFormat=@{project.artifactId}-@{project.version}
scm.tag=project-1.0.0
project.scm.group.id\:project.tag=HEAD
pushChanges=true
scm.url=scm\:svn\:http\://svn.server/svn/repos/.../project/trunk
preparationGoals=clean verify
remoteTagging=true
projectVersionPolicyId=default
scm.commentPrefix=[maven-release-plugin] 
scm.tagBase=http\://svn.server/svn/repos/.../project/branches
project.scm.group.id\:project.developerConnection=scm\:svn\:http\://svn.server/svn/repos/.../project/trunk
project.dev.group.id\:project=1.0.1-SNAPSHOT
project.rel.group.id\:project=1.0.0
exec.snapshotReleasePluginAllowed=false
exec.additionalArguments=-P my-active-profile
completedPhase=end-release

pom.xml.tag:

...
<scm>
    <developerConnection>scm:svn:http://svn.server/svn/repos/.../project/tags/project-1.0.0</developerConnection>
</scm>
...

It looks like the scm.tagBase property is correct in the generated release.properties file, but the scm information in pom.xml.tag still references the tags directory instead of branches.

1
Did you clean the release before anything? It could be that you're reading old files. Run mvn release:clean release:prepare -DdryRun=true, this will make sure the release.properties and pom.xml.tag are recreated. - Tunaki
Thanks for the suggestion. Yeah, I've tried quite a few things so far. In between each of the mvn release:prepare commands I've tried, I've been running an mvn release:clean, but it still seems to be ignoring the tagBase setting. - Josh

1 Answers

1
votes

I started digging through the maven-release-plugin code and the maven-scm-provider-svn-commons code, and I'm pretty sure I've figured out why this is happening.

If the tagBase property matches the standard naming convention for the branches directory in an SVN repository (for example, http://svn.server/svn/repo/project/branches), then the tagBase gets ignored in favor of the standard tags directory. Here's the relevant code from version 1.9.4 of the maven-scm-provider-svn-commons project:

SvnTagBranchUtils.java:

public static String resolveUrl( String repositoryUrl, String tagBase, String subdir, ScmBranch branchTag )
{
    ...
    // User has a tagBase specified so just return the name appended to the tagBase
    if ( StringUtils.isNotEmpty( tagBase ) && !tagBase.equals( resolveTagBase( repositoryUrl ) )
        && !tagBase.equals( resolveBranchBase( repositoryUrl ) ) )
    {
        return appendPath( tagBase, branchTagName );
    }
    ...
    return addSuffix( appendPath( appendPath( projectRoot, subdir ), branchTagName ), queryString );
}

The !tagBase.equals( resolveBranchBase( repositoryUrl) ) condition prevents the tagBase from being used if it matches the standard /branches/ directory in the SVN repository layout. I was even able to test this out using a different tagBases that didn't match the /branches/ directory (for example, http://svn.server/svn/repo/.../project/releases) and it worked as expected.

Unfortunately, I'm still not 100% sure about the best way to have the releases written to /branches/ when running mvn release:prepare. I'm thinking I might just modify that bit of code in maven-scm-provider-svn-commons and figure out a way to get the maven-release-plugin to use my modified version of svn-commons.

Anyways, I hope this might help anyone who's trying to do something similar with the maven-release-plugin.