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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With