Hi,

I still stand by my claim that the story of releasing a single module in a
hg multi-module repository is currently not possible. Now you might say,
that this is against conventions, and you should always release the whole
repository, but usage of of maven and mercurial differs, and after all it's
"convention over configuration" and not "convention or not at all".

In this E-Mail I will prove to you that this is not possible, if you will
follow me through the following steps. If at any point I missed an option I
would like you to raise your voice :)

*Step 1*

So, I started with a very simple multi-module project (/pom.xml and
/multi/pom.xml) and tried to release just a single module (multi). It turned
out that this is not possible, because during the release:perform phase, the
whole hg repository is checked out, and the build is started in the root of
that repository.

=> Use the latest maven-release-plugin:2.2-SNAPSHOT in which
MRELEASE-457<http://jira.codehaus.org/browse/MRELEASE-457>is fixed.

*Step 2*

The new dependencies with the snapshot release plugin also updates to a
newer hg scm provider. The new hg scm provider has the interesting new habit
to throw an exception, when you want to tag something, which does not
concern the whole repository.

Caused by: org.apache.maven.scm.ScmException: This provider doesn't support
tagging subsets of a directory
        at
org.apache.maven.scm.provider.hg.command.tag.HgTagCommand.executeTagCommand(HgTagCommand.java:77)
        at
org.apache.maven.scm.command.tag.AbstractTagCommand.executeCommand(AbstractTagCommand.java:81)
        at
org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:59)
        ... 29 more

=> Update the dependencies of maven-release-plugin:2.2-SNAPSHOT to use
maven-scm-provider-hg:1.4

*Step 3
*
The next step was to move the parent pom out of the root of the hg
repository. We have a standardized layout in our hg repositories (to take
into account various tradeoffs between maven, m2eclipse, hudson, etc.) that
we have all projects in directories under the root directory. So I tried to
have
/ root / pom.xml (having a module ../multi)
and
/ multi / pom.xml (having a parent ../root)

The release plugin did not like that at all:

[INFO] EXECUTING: cmd.exe /X /C "hg commit --message "[maven-release-plugin]
prepare release root-1.6" C:\Temp\releasetest\parent\pom.xml
C:\Temp\releasetest\multi\pom.xml"
[INFO] EXECUTING: cmd.exe /X /C "*hg push file:///C:/Temp/releasetestrepo*"
[INFO] Tagging release with the label root-1.6...
[INFO] EXECUTING: cmd.exe /X /C "hg tag --message "[maven-release-plugin]
copy for tag root-1.6" root-1.6"
[INFO] EXECUTING: cmd.exe /X /C "*hg push file:///C:/Temp*"
[ERROR]
EXECUTION FAILED
  Execution of cmd : push failed with exit code: -1.
  Working directory was:
    c:\temp\releasetest
  Your Hg installation seems to be valid and complete.
    Hg version: 1.6.2 (OK)


This is probably a bug, but I have no idea if this is in the scm provider,
release plugin, shared components, ... I'm glad to create a jira issue for
it, but would like to do so for the right project.

=> Having no pom.xml in the root of the repository is apparently a bad idea.
But we need to have our "parent" in a folder under the root directly. So I
created a thin dummy pom, which just has the real parent as module.

*Step 4*

So we now have:
/ pom.xml
/ parent / pom.xml
/ multi / pom.xml

While I created the root pom.xml, I tried to optimize a bit and included
localCheckout=true to the plugin configuration, so that the tag checkout
does not happen from the remote repository, but from the local one. Bad
idea:

[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.2-SNAPSHOT:perform
(default-cli) on project root: The scm url is invalid.
[ERROR] - An hg 'file' url must be on the form 'file:///' or
'file://localhost/'.

My scm url is: scm:hg:file:///C:/Temp/releasetestrepo

So also the "remote" hg repository is on the local filesystem, but when the
local checkout occurs, the url is apparently not constructed correctly.

=> Ok, no localCheckout. Not a big deal, moving on.

*Step 5*

If possible, I don't want the /parent/pom.xml to inherit from /pom.xml,
because it may well be, that it needs to inherit from something completely
different. I only wanted to use the /pom.xml as a forwarder to
/parent/pom.xml. So I tried that, and tried to release the "multi"-module. I
did this by running from working directory /parent the command "mvn
--batch-mode -pl multi release:prepare". But I could not find a working scm
configuration in /parent/pom.xml

When it was set to "scm:hg:file:///C:/Temp/releasetestrepo/parent" I got
this error - apperently it tried to replace the current module name "parent"
in the scm url with "multi":
[INFO] EXECUTING: cmd.exe /X /C "hg commit --message "[maven-release-plugin]
prepare release multi-1.22" C:\Temp\releasetest\multi\pom.xml"
[INFO] EXECUTING: cmd.exe /X /C "hg push *
file:///C:/Temp/releasetestrepo/multi*"

But when I set the scm url to the correct value
"scm:hg:file:///C:/Temp/releasetestrepo" it removed the last path element:
[INFO] EXECUTING: cmd.exe /X /C "hg commit --message "[maven-release-plugin]
prepare release multi-1.22" C:\Temp\releasetest\multi\pom.xml"
[INFO] EXECUTING: cmd.exe /X /C "hg push *file:///C:/Temp/multi*"

==> so apparently the /parent/pom.xml needs to inherit from /pom.xml and scm
info should be in the root.

*Step 6*

So I tried that but ran into problems again!

C:\Temp\releasetest>mvn -pl multi --offline --batch-mode release:prepare
[INFO] Checking in modified POMs...
[INFO] EXECUTING: cmd.exe /X /C "hg commit --message "[maven-release-plugin]
prepare release multi-1.28" C:\Temp\releasetest\multi\pom.xml"
[INFO] EXECUTING: cmd.exe /X /C "hg push file:///C:/Temp/multi"
[ERROR]
EXECUTION FAILED
  Execution of cmd : push failed with exit code: -1.
  Working directory was:
    C:\Temp\releasetest\multi
  Your Hg installation seems to be valid and complete.
    Hg version: 1.6.2 (OK)

=> This means, the scm configuration has to be present in every module, even
if it is absolutely the same everywhere.

*Step 7*

So I got it working in an example project, but the fact, that I have to copy
the scm configuration into every module, makes that solution impossible to
rollout to any serious production environment.

If there is anything that I missed, please let me know!

For the sake of everybody, here are the poms, and how I ran the command:

*/pom.xml*

<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <groupId>de.aek.test</groupId>
    <artifactId>root</artifactId>
    <version>1.12-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>parent</module>
    </modules>

    <scm>
        <connection>scm:hg:file:///C:/Temp/releasetestrepo</connection>

<developerConnection>scm:hg:file:///C:/Temp/releasetestrepo</developerConnection>
    </scm>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.2-SNAPSHOT</version>
                <configuration>

<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
                    <goals>install</goals>
                    <resume>false</resume>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-provider-hg</artifactId>
                        <version>1.4</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <pluginRepositories>
        <pluginRepository>
            <id>apache.snapshots</id>
            <name>Apache Snapshots</name>
            <url>https://repository.apache.org/content/groups/snapshots/
</url>
        </pluginRepository>
    </pluginRepositories>
</project>

*/parent/pom.xml*

<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>de.aek.test</groupId>
        <artifactId>root</artifactId>
        <version>1.10</version>
        <relativePath>..</relativePath>
    </parent>

    <groupId>de.aek.test</groupId>
    <artifactId>parent</artifactId>
    <version>1.13-SNAPSHOT</version>
    <packaging>pom</packaging>

    <scm>
        <connection>scm:hg:file:///C:/Temp/releasetestrepo</connection>

<developerConnection>scm:hg:file:///C:/Temp/releasetestrepo</developerConnection>
    </scm>

     <modules>
        <module>../multi</module>
    </modules>

</project>

*/multi/pom.xml*

<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>de.aek.test</groupId>
        <artifactId>parent</artifactId>
        <version>1.12</version>
        <relativePath>../parent</relativePath>
    </parent>

    <groupId>de.aek.test</groupId>
    <artifactId>multi</artifactId>
    <version>1.27-SNAPSHOT</version>
    <packaging>pom</packaging>

    <scm>
        <connection>scm:hg:file:///C:/Temp/releasetestrepo</connection>

<developerConnection>scm:hg:file:///C:/Temp/releasetestrepo</developerConnection>
    </scm>

</project>

*preparing and performing a release
*
C:\Temp\releasetest>mvn -pl multi --offline --batch-mode release:prepare
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building multi 1.27-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.2-SNAPSHOT:prepare (default-cli) @ multi
---
[INFO] Verifying that there are no local modifications...
[INFO]   ignoring changes on: pom.xml.next, release.properties,
pom.xml.releaseBackup, pom.xml.backup, pom.xml.branch, pom.xml.tag
[INFO] EXECUTING: cmd.exe /X /C "hg status"
[INFO] Not a file: C:\Temp\releasetest\multi\multi\release.properties.
Ignoring
[INFO] Ignoring SNAPSHOT depenedencies and plugins ...
[INFO] Transforming 'multi'...
[INFO] Not generating release POMs
[INFO] Executing goals 'clean verify'...
[INFO] [INFO] Scanning for projects...
[INFO] [INFO]
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] [INFO] Building multi 1.27
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] [INFO]
[INFO] [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ multi ---
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] [INFO] Total time: 1.063s
[INFO] [INFO] Finished at: Thu Mar 03 15:52:50 CET 2011
[INFO] [INFO] Final Memory: 2M/5M
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] EXECUTING: cmd.exe /X /C "hg commit --message "[maven-release-plugin]
prepare release multi-1.27" C:\Temp\releasetest\multi\pom.xml"
[INFO] EXECUTING: cmd.exe /X /C "hg push file:///C:/Temp/releasetestrepo"
[INFO] Tagging release with the label multi-1.27...
[INFO] EXECUTING: cmd.exe /X /C "hg tag --message "[maven-release-plugin]
copy for tag multi-1.27" multi-1.27"
[INFO] EXECUTING: cmd.exe /X /C "hg push file:///C:/Temp/releasetestrepo"
[INFO] EXECUTING: cmd.exe /X /C "hg locate"
[INFO] Transforming 'multi'...
[INFO] Not removing release POMs
[INFO] Checking in modified POMs...
[INFO] EXECUTING: cmd.exe /X /C "hg commit --message "[maven-release-plugin]
prepare for next development iteration" C:\Temp\releasetest\multi\pom.xml"
[INFO] EXECUTING: cmd.exe /X /C "hg push file:///C:/Temp/releasetestrepo"
[INFO] Release preparation complete.
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 7.625s
[INFO] Finished at: Thu Mar 03 15:52:52 CET 2011
[INFO] Final Memory: 3M/7M
[INFO]
------------------------------------------------------------------------
C:\Temp\releasetest>mvn -pl multi --offline --batch-mode release:perform
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building multi 1.28-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.2-SNAPSHOT:perform (default-cli) @ multi
---
[INFO] Checking out the project to perform the release ...
[INFO] Removing C:\Temp\releasetest\multi\target\checkout
[INFO] EXECUTING: cmd.exe /X /C "hg clone -r multi-1.27
file:///C:/Temp/releasetestrepo C:\Temp\releasetest\multi\target\checkout"
[INFO] EXECUTING: cmd.exe /X /C "hg locate"
[INFO] Invoking perform goals in directory
C:\Temp\releasetest\multi\target\checkout\multi
[INFO] Executing goals 'install'...
[INFO] [INFO] Scanning for projects...
[INFO] [WARNING]
[INFO] [WARNING] Some problems were encountered while building the effective
model for de.aek.test:multi:pom:1.27
[INFO] [WARNING] 'build.plugins.plugin.version' for
org.apache.maven.plugins:maven-javadoc-plugin is missing.
[INFO] [WARNING] 'build.plugins.plugin.version' for
org.apache.maven.plugins:maven-deploy-plugin is missing.
[INFO] [WARNING] 'build.plugins.plugin.version' for
org.apache.maven.plugins:maven-source-plugin is missing.
[INFO] [WARNING]
[INFO] [WARNING] It is highly recommended to fix these problems because they
threaten the stability of your build.
[INFO] [WARNING]
[INFO] [WARNING] For this reason, future Maven versions might no longer
support building such malformed projects.
[INFO] [WARNING]
[INFO] [INFO]
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] [INFO] Building multi 1.27
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] [INFO]
[INFO] [INFO] >>> maven-source-plugin:2.1.2:jar (attach-sources) @ multi >>>
[INFO] [INFO]
[INFO] [INFO] <<< maven-source-plugin:2.1.2:jar (attach-sources) @ multi <<<
[INFO] [INFO]
[INFO] [INFO] --- maven-source-plugin:2.1.2:jar (attach-sources) @ multi ---
[INFO] [INFO]
[INFO] [INFO] --- maven-javadoc-plugin:2.7:jar (attach-javadocs) @ multi ---
[INFO] [INFO] Not executing Javadoc as the project is not a Java
classpath-capable package
[INFO] [INFO]
[INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install) @
multi ---
[INFO] [INFO] Installing
C:\Temp\releasetest\multi\target\checkout\multi\pom.xml to C:\Dokumente und
Einstellungen\aek\.m2\repository\de\aek\test\multi\1.27\muti-1.27.pom
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] [INFO] Total time: 8.843s
[INFO] [INFO] Finished at: Thu Mar 03 15:53:11 CET 2011
[INFO] [INFO] Final Memory: 5M/10M
[INFO] [INFO]
------------------------------------------------------------------------
[INFO] Cleaning up after release...
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 12.797s
[INFO] Finished at: Thu Mar 03 15:53:11 CET 2011
[INFO] Final Memory: 3M/7M
[INFO]
------------------------------------------------------------------------

-- 
Mit freundlichen Grüßen / Best regards

Andreas Ebbert-Karroum | Bereichsleiter der Agilen Software Factory

codecentric AG | Merscheider Straße 1 | 42699 Solingen | Deutschland
tel: +49 (0) 212.23362825 | fax: +49 (0) 212.23362879 | mobil: +49 (0)
175.2664109
www.codecentric.de | blog.codecentric.de | www.meettheexperts.de |
www.more4fi.de

Sitz der Gesellschaft: Düsseldorf | HRB 63043
Vorstand: Klaus Jäger (Vorsitzender) | Mirko Novakovic . Rainer Vehns
Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Bernd Klinkmann . Jürgen
Schütz

Diese E-Mail einschließlich evtl. beigefügter Dateien enthält vertrauliche
und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige
Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie
bitte sofort den Absender und löschen Sie diese E-Mail und evtl. beigefügter
Dateien umgehend. Das unerlaubte Kopieren, Nutzen oder Öffnen evtl.
beigefügter Dateien sowie die unbefugte Weitergabe dieser E-Mail ist nicht
gestattet.

Reply via email to