git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: request for help with buildnumber-maven-plugin git integration

From
Adam Monsen <haircut@gmail.com>
Date
May 27, 2010, 04:15 UTC
Message-ID
<loom.20100527T061506-817@post.gmane.org>
In-Reply-To
<loom.20100514T010951-900@post.gmane.org>
I wrote, about a week ago:
Show 8 quoted lines
> Maven is a build system used by many Java-based projects. Some
> folks have added Git support, allowing the inclusion of build
> identifiers (like branches and commit hashes) in products of Maven
> builds. But they need help to complete it. Is anyone interested in
> helping?
>
> This is something we (Mifos) need, so if you do help, know that
> you'll be helping to end world poverty.

FYI, I gave up trying to fix the integration tests, or to modify the plugin to suit my needs. I instead used groovy script right in my POM, and set project properties that are filtered into a file included in our war.

Here's the Groovy snippet I used, modified to have shorter names to prevent wrapping:

  def env = System.getenv()
  def gitcmd = "git"
  if (env['OS'] =~ /^Windows/)
      gitcmd = "cmd /c ${gitcmd}"
  def gcmd = """${gitcmd} log --pretty=format:%H -n1""".execute()
  project.properties['mifos_commit'] = gcmd.in.text
  project.properties['mifos_build'] = env['BUILD_TAG'] ?: 'DEV'
  project.properties['mifos_date'] = "" + new Date()

"BUILD_TAG" is something set by the Hudson continuous integration server (that's what we use).

Here's the script, in vivo (commit 5dfe4d1abda09713b296ea2524): http://tinyurl.com/3xcxp9n

I figured trading lots of lines of Java, XML, etc. for 8 lines of maintainable/portable Groovy was a good move.

Hope this helps someone else using Maven and git who needs build identifiers available as properties, -Adam

Previous: Adam Monsen
Message 2 of 2 in “request for help with buildnumber-maven-plugin git integration”
  1. Adam MonsenMay 13, 2010
  2. Adam MonsenMay 27, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.