Question

I just used maven-release-plugin to release a version, obviously :) The scm configuration in my parent pom is as follows:

<scm>
    <developerConnection>scm:svn:http:/localhost/svn/project/trunk/project/3. Implementation/02 Source code</developerConnection>
</scm>

As you can see, after trunk we have several more folders (RUP-style) before reaching the source code.

A mvn release:prepare results in the following scm configuration:

<scm>
    <developerConnection>scm:svn:http://localhost/svn/project/tags/project-1.0.0/02 Source code</developerConnection>
</scm>

So, somehow, maven-release-plugin manages to replace trunk/project/3. Implementation/02 Source code with tags/project-1.0.0/02 Source code.

Why would this not be tags/project-1.0.0, as I would expect? If I would run mvn release:perform the plugin would checkout the entire 3. Implementation directory.

For reference, my plugin definition is as follows:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
    <version>2.5</version>
        <configuration>
            <tagBase>http://localhost/svn/project/tags</tagBase>
        </configuration>
    </plugin>
</plugins>
Was it helpful?

Solution

Right, I figured out what causes this, looking at the maven-release-manager source code. When rewriting the developerConnection value, the RewritePomsForReleasePhase class calculates the number of subdirectories we need to remove from the developerConnectionUrl to get to the root of our project, based on the local project. Now there are two problems with this approach:

  1. There is no guarantee the local depth will match the remote one. Although this may be best practice.
  2. The working dir (from where mvn is called) does not have to be in the root of the project.

Both apply to my situation. I checked out the project two directories less deep than remote. To clarify: http://localhost/project/3. Implementation/02 Source code was checked out to D:\workspace\project

Also, we have a project-parent dir containing our parent pom.

So now it determines we are 1 deep by looking at the local structure (from work dir, i.e. project-parent, to project dir) and applies this to the developerConnection url. Then it does a substring on the original developerConnection with the result and ends up with 02 Source code in my case.

So long story less long: maven-release-plugin does not work as expected when the local directory structure does not match the remote one. Now I have to checkout honoring the server path and also create a new pom, or move the parent pom to the project root to get it to work...

EDIT: Moving the pom to the project base dir would probably fix the issue, leaving the developerConnection url unchanged. Will confirm this for the next release.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top