Using maven-release-plugin to tag and commit to non-origin
-
26-09-2019 - |
Question
When I do a release of my project, I want to share the source with a wider group of people than I normally do during development. The code is shared via a Git repository. To do this, I have used the following:
- remote public repository - released code is pushed here, every week or so (http://example.com/public)
- remote private repository - non-release code is pushed here, more than daily (http://example.com/private)
In my local git repository, I have the following remotes defined:
origin http://example.com/private
public http://example.com/public
I am currently trying to configure the maven-release-plugin to manage versioning of the builds, and to manage tagging and pushing of code to the public repository. In my pom.xml, I have listed the <scm/> as follows:
<scm><connection>scm:git:http://example.com/public</connection></scm>
(Removing this line will cause mvn release:prepare to fail)
However, when calling
mvn release:clean release:prepare release:perform
Maven calls
git push origin tagname
rather than pushing to the URL specified in the POM.
So the questions are:
- Best practice: Should I just be tagging and committing in my private repo (origin), and pushing to public manually?
- Can I make Maven push to the repository that I choose, rather than defaulting to origin? I felt this was implied by the requirement of the <connection/> element in <scm/>.
Solution
Releasing when the scm.connection repository is different to the origin is fixed in the version 2.0 of maven-release-plugin (or the associated git plugins). To change to this version, I added the following to my POM:
<project>
...
<build>
<plugins>
...
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
</plugin>
...
</plugins>
</build>
...
</project>
Incidentally, Maven was picking up maven-release-plugin version 2.0-beta-9 as being more recent than 2.0.