Maven Release with Flat Project Structures Revisited

26 01 2010

You may recall my previous blog on Maven Release Woes with Flat Project Structures where I described in detail how the supposed 2.0-beta-10-SNAPSHOT flat structure release support did not perform as expected. After some back and forth with one of the Apache developers, it has come to light that this conclusion is partially correct. The term “flat structure” is contextual and in this particular context, the Apache group’s idea of context was SCM. SCM structure is what needs to be in one of a few known structures for the release plugin to function appropriately. In the end, another JIRA ticket was created for a different use case, albeit very similar to the previously closed ticket. I’ll review what flat structure does work and some variations that don’t.

SCM Structures
First, let’s understand the structures the release plugin does support. Here is your typical nested multi-module project structure that’s supported and recommended (remember SCM structure):


Now let’s take a look at the SCM flat structure that the release plugin will support, provided you’re using at least 2.0-beta-10-SNAPSHOT:


You can see that all the projects of the multi-module project are flat, behind trunk. If you have multiple projects in your SCM, I’d recommend breaking them up with project names at the SCM root, similar to what I have done here with flat-structure-test. If not, when the release plugin goes to tag your code, it will tag everything behind trunk, not just the folders your multi-module project uses. Another thing recommended to me by the developer was to use a particular configuration, -DcommitByProject=true. For example:

emiles-macbook:release-parent emiles$ mvn release:prepare -DcommitByProject=true

With this diagramed, you must still be mindful that projects must be structured completely flat behind trunk. For testing purposes, I tried a slightly altered flat structure where release-module2 was under a random, non-project folder under trunk named somesubfolder.


This structure passed the prepare goal just fine, but when it came time to actually perform the release, it failed with an SCM checkout failure.

INFO] [INFO] Scanning for projects...
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Error building POM (may not be this project's POM).
[INFO] Project ID: unknown
[INFO] Reason: Could not find the model file '/Users/emiles/Projects/release-workspace/release-parent/target/checkout/release-module2'. for project unknown
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Trace
[INFO] org.apache.maven.reactor.MavenExecutionException: Could not find the model file '/Users/emiles/Projects/release-workspace/release-parent/target/checkout/release-module2'. for project unknown

While a specific flat project structure use case is supported, you must be mindful of the SCM structure as slight variations may not work with the release plugin. As I recommended in my previous blog, use the nested structure for multi-module projects if you can. If your project structures already exist in SCM, if possible, restructure them to model the nested structure.

Be on the lookout for my next blog article providing some suggestions on how to tackle releases if you’re stuck in an SCM structure that the release plugin does not support.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: