Maven Buildnumber plugin - Git
Asked Answered
S

7

18

The Maven Buildnumber plugin doesn't appear to work with GIT yet. Is there a workaround for the time being? I recently switched from SVN to GIT and have found it to be an easy transition, but this is the only thing that I don't have working presently.

Walter

Selah answered 21/4, 2010 at 17:17 Comment(0)
C
6

Well, there is MOJO-1199 about the buildnumber plugin and GIT support but the patches haven't been applied yet. However, it seems that Antony Stubbs did some work around this and made it available in this git mirror. Have a look at it.

Crackerjack answered 21/4, 2010 at 19:3 Comment(6)
Hi guys! I have spies everywhere ;) Yes, it is weird. Seems the plugin may be essentially abandoned. Me and a friend of mine are toying with the idea of publishing the fork to repo1.Cates
I just chatted with pgier and wsmoak on irc.codehaus.org#maven, they said if the patch applies cleanly, they'll accept in the buildnumber-maven-plugin.Hostile
From Antony (or Justin?) - "I use my build every day, it definitely works for me. However, yes, I noticed the failure and disabled the tests! ;) but yes, the git integration works fine. I welcome a patch to fix the integration tests". I'll try to get to this soon. I recall maven plugin integration tests being kinda hard to debug, so I'll probably ask for help on some mailing lists.Hostile
The issue MOJO-1199 has been marked as resolved. In case you need branch info, there's still MBUILDNUM-66.Ontine
As from now, even given that MOJO-1199 has been marked as resolved and builnumber-maven-plugin has 1.2 version the issue is still there :(Purposeless
I've tried 1.0, 1.1, 1.2, and 1.3 versions of the plugin and the issue mentioned in this comment to MOJO-1199 still exists, which excludes using of this plugin from any build which is not on master branch.Letaletch
H
12

I use this Maven plugin:

https://github.com/ktoso/maven-git-commit-id-plugin

and have it filter values directly into my spring files where I can inject them into anything I want (mostly just for reporting versions at start-up / or via a REST service).

When first starting, set it up to generate the properties file so you can see everything that is available. Extremely easy to use. Love it.

Holladay answered 3/11, 2012 at 12:54 Comment(2)
Thanks for recommending it! I'm really trying to keep it updated as new feature requests come in :-) If you have any problems feel free to ping me via github issues! // I'm the author of this plugin.Nomo
I must did something wrong. In my project github.com/actframework/actframework/blob/master/pom.xml, I just can't get the maven-git-commit-id-plugin working :-(Ashlar
K
11

I have written a blog post that describes how you can use the buildnumber-maven-plugin to add the Git SHA-1 to your project.

For the record, I used version 1.0 of the plugin, which was released in April 2011.

Kissie answered 7/4, 2012 at 14:4 Comment(2)
One hint: If you add <connection>scm:git:git://localhost/${basedir}</connection>, you can use the plugin in every build directory regardless of which remote SCM URL you have. This simplifies configuration a little bit.Selfconsistent
@Kissie Thank you Mattias. In the past, we have implemented a plugin themselves (and I think it is not good). This solution works for me with: maven-scm-plugin:1.9.4; buildnumber-maven-plugin:1.4; maven-jar-plugin:2.6Gimble
C
6

Well, there is MOJO-1199 about the buildnumber plugin and GIT support but the patches haven't been applied yet. However, it seems that Antony Stubbs did some work around this and made it available in this git mirror. Have a look at it.

Crackerjack answered 21/4, 2010 at 19:3 Comment(6)
Hi guys! I have spies everywhere ;) Yes, it is weird. Seems the plugin may be essentially abandoned. Me and a friend of mine are toying with the idea of publishing the fork to repo1.Cates
I just chatted with pgier and wsmoak on irc.codehaus.org#maven, they said if the patch applies cleanly, they'll accept in the buildnumber-maven-plugin.Hostile
From Antony (or Justin?) - "I use my build every day, it definitely works for me. However, yes, I noticed the failure and disabled the tests! ;) but yes, the git integration works fine. I welcome a patch to fix the integration tests". I'll try to get to this soon. I recall maven plugin integration tests being kinda hard to debug, so I'll probably ask for help on some mailing lists.Hostile
The issue MOJO-1199 has been marked as resolved. In case you need branch info, there's still MBUILDNUM-66.Ontine
As from now, even given that MOJO-1199 has been marked as resolved and builnumber-maven-plugin has 1.2 version the issue is still there :(Purposeless
I've tried 1.0, 1.1, 1.2, and 1.3 versions of the plugin and the issue mentioned in this comment to MOJO-1199 still exists, which excludes using of this plugin from any build which is not on master branch.Letaletch
F
6

I used buildnumber-maven-plugin with git for some time. But one day our manager was unable to setup Git CLI (in win7 with non ASCII user name). It forced me to write maven plugin using JGit API without git command line. See maven-jgit-buildnumber-plugin.

Fogg answered 15/3, 2012 at 20:28 Comment(2)
For non standard git installs (especially Windows) this makes dealing with the build far easier.Grubman
Thank you, Alex! I also added more features to your plugin: github.com/elab/jgit-buildnumber (released to Maven Central as well)Veneaux
M
3

This blog post describes how to use profiles to have the buildnumber plugin work differently when in a git or svn working copy.

Obviously(*) the buildnumber created in the git repository does not contain the subversion revision number.

(*) It should be possible to include the subversion revision number in the buildnumber when working in a git repository for commits that are already pushed back to the subverion repository.

Mcmillin answered 31/5, 2011 at 11:33 Comment(0)
P
3

The current version of buildNumber plugin - 1.0 - supports the Git SCM. In the version 1.1-SNAPSHOT there is a new configuration tag shortRevisionLength for getting the short git id. More details http://yevgen-fr.blogspot.com/2012/02/maven-buildnumber-plugin-short-revision.html

Poona answered 16/2, 2012 at 12:52 Comment(0)
C
2

I had problems with getting the ones provided above to work.

So I wrote my own, which simply executes the git describe and assigns to a property to be used in the MANIFEST.MF.

See: https://github.com/koekiebox/git-maven-plugin

Thanks.

Calceiform answered 16/10, 2013 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.