Reputation: 4448
I'm trying to release a multi-module maven project that uses git as the SCM, and among the first problems I've encountered is the way in which the maven release plugin builds the release.properties scm.url. My parent POM looks something like this:
<packaging>pom</packaging>
<groupId>org.project</groupId>
<artifactId>project-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scm>
<connection>scm:git:git://github.com/username/project.git</connection>
<developerConnection>scm:git:[email protected]:username/project.git</developerConnection>
<url>http://github.com/username/project</url>
</scm>
<modules>
<module>api</module>
<module>spi</module>
</modules>
And the module POMs are straightforward:
<parent>
<groupId>org.project</groupId>
<artifactId>project-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>api</artifactId>
<version>0.2.2</version>
My goal is to be able to release individual modules since they each have different versions and I don't want to increment all of the versions together each time I do a release.
When I change to the api
directory and do a mvn release:clean release:prepare
I'm met with the following output:
[INFO] Executing: cmd.exe /X /C "git push [email protected]:username/project.git/api master:master"
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to commit files
Provider message:
The git-push command failed.
Command output:
ERROR: Repository not found.
It looks like the maven release plugin creates the scm.url by appending the module name to the developerConnection
, which ends up not being a valid repository at github. I'm not sure what the right way to set this up is. It might be the case that Maven + git + releasing an individual child module simply won't work? Any input is appreciated.
Upvotes: 30
Views: 38549
Reputation: 2508
I answered to a related question here (multi-module with multi-repository). basically, you can use a property called commitByProject, since maven-release-plugin 2.0-beta-5, that lets you commit per project each submodule (referenced from root pom with 'git submodule add' strategy also works).
mvn release:prepare -DcommitByProject=true
Upvotes: 0
Reputation: 367
I know this is late for a response but I ran into this same issue and the only solution where you could achieve both, a multi module maven project, and independent releases for each module is when you do the following:
Essentially, within git each maven module will exist as a project of its own. There will be a separate git project for the maven parent project but it will not contain the actual modules, only git submodule links to the git location where actual projects are stored.
Upvotes: 0
Reputation: 810
A simple way, what worked for me is to use the parent properties in the modules pom.xml
like follow in the scm
tag like follow:
<!--module pom.xml-->
<scm>
<connection>${project.parent.scm.connection}</connection>
<developerConnection>${project.parent.scm.developerConnection}</developerConnection>
</scm>
Upvotes: 1
Reputation: 707
I was trying to do a similar thing for a long time, and never found a good solution, so wrote my own release plugin for git. It only releases changed modules, you don't need any scm config, it tags based on the module names, and inter-component dependencies work.
Documentation: http://danielflower.github.io/multi-module-maven-release-plugin/index.html
Introduction blog: http://danielflower.github.io/2015/03/08/The-Multi-Module-Maven-Release-Plugin-for-Git.html
Upvotes: 2
Reputation: 722
For anyone that comes to this question in search of a good solution as I did, what I found that works for me is the following:
http://blog.avisi.nl/2012/02/15/maven-release-plugin-setup-guide-for-git/
You still 'tag' off the entire trunk because that's how git works but it allows to you only build/version/deploy the submodule that you want to.
Upvotes: 1
Reputation: 116828
I found this question with a search on "git-push command failed". I have a similar configuration where I have a master-pom and then submodules that I release as their own maven packages.
To get it to work I had to tune the scm
section of the pom.xml
to something like the following. The connections specifically had to be tuned right to work. None of the github ones worked at all.
<scm>
<url>https://github.com/XXX/YYY</url>
<connection>scm:git:ssh://[email protected]/XXX/YYY.git</connection>
<developerConnection>scm:git:ssh://[email protected]/XXX/YYY.git</developerConnection>
</scm>
The XXX
in the above example is your github username. You cannot use the :XXX
format ([email protected]:XXX/...
) because the value past the :
is interpreted as being a port number instead. The YYY
is obviously your repository name under the XXX
account.
I just released all 3 of my submodules one-by-one using this pattern successfully.
Upvotes: 14
Reputation: 99993
To see how to make this work, have a look at a working example, such as:
https://github.com/sonatype/sonatype-aether
However, this won't help if you like to release the individual pieces. In that case, you have to just copy the <scm> elements into all the poms.
This is an active topic of discussion on the maven dev list, but don't hold your breath for a solution from there; it's a big deal.
Upvotes: 14