Dynamically Setting the Name of the output of a Maven build
I came across
this post at DZone where essential the author was complaining that he couldn't set the name of the build product in Maven without modifying the pom.xml file. In his case he wanted to pull the version number from Git. The solution was actually pretty straightforward with a little scripting help from
GMaven. Here's an example
<plugins>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>groovy-magic</id>
<phase>prepare-package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
def scmversion = 'git describe'.execute().text.trim()
project.build.finalName = "${project.artifactId}-${scmversion}"
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
0 comments:
Post a Comment