Releasing multiple Maven artifacts when using nested Git submodules

git, git-submodules, maven, maven-release-plugin, release

Solution

The answer to this question isn't going to satisfy the initial question, but the Maven Release plugin isn't smart enough to understand git submodule boundaries. I think what you are looking for is the ability for the Maven Release plugin to sense that a directory points to a submodule and for this release plugin to automatically tag across boundaries? This won't happen, and I don't think it is on anyone's plan at this point.

What I always recommend for Maven users who use Git is never break the boundaries of a multi-module project that needs to use the Release plugin across submodules. Keep it confined to a single repository.

Again, this isn't a great answer, but having used the Maven Release Plugin for many years, it is also true that it isn't a great plugin :-(

Problem

I have been searching for a while now and could not find any working solution or guide/tutorial for releasing Maven modules when using nested Git submodules. We have a complex structure of public and private projects that require a specific order to build successfully. Our goal is to perform a Maven release in order to tag and deploy multiple Maven artifacts in a single step. Here is the simplified Maven project/modules and Git repository structure: ``` parent-public:1.0.0:pom (descriptor only, no Maven modules, public Git repository) | | | |- public-module:1.0.0-SNAPSHOT:jar | (Maven module, child of parent-public, Git submodule, public repository) | |- parent-private:1.0.0-SNAPSHOT:pom (Maven modules, Git submodule, private repository) | |- public-module:1.0.0-SNAPSHOT:jar | (Maven module only, child of parent-public, Git submodule, public repository, released) | |- private-module:1.0.0-SNAPSHOT:war (Maven module, child of parent-private, released) ``` The current structure allows Maven to build and deploy projects/modules independently. When releasing `public-module` (from the parent-public/parent-private/public-module directory), the `maven-release-plugin` performs well (Git repository has been tagged and release artifact has been deployed). When releasing `parent-private`, the `maven-release-plugin` prepares and starts performing the release before failing during the target checkout (this problem is discussed here, but solution is not working in my context and not enough reputation to comment). Here is the current `maven-release-plugin` configuration: ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.3.2</version> <configuration> <tagNameFormat>v@{project.version}</tagNameFormat> <commitByProject>true</commitByProject> <pushChanges>true</pushChanges> </configuration> </plugin> ``` Is there a more elegant way to organize Maven modules and Git repositories in order to release multiple Maven artifacts? Alternatively, did someone find a solution to clone recursively Git submodules during checkout just before deploying artifacts?

Original source

Related problems