svnmaven-2maven-scmmaven-ear-plugin

How to configure Hudson/Maven2 to add SVN revision to name of EAR?


We use Hudson, Maven2 and maven-ear-plugin.

Is it possible to have the built EAR files to contain SVN revision in their filename (something like project-1234.ear)?


Solution

  • You can use the buildnumber-maven-number for this. Basically, this plugin sets a ${buildNumber} property that you can use later in the maven ear plugin configuration.

    First, setup the Build Number Maven Plugin as documented here:

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.0-beta-4</version>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>create</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <doCheck>true</doCheck>
          <doUpdate>true</doUpdate>
        </configuration>
      </plugin>
      ...
    </plugins>
    

    Then, use the finalName parameter to customize the name of the generated ear. For example:

    <plugins>
      ...
      <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <finalName>${project.artifactId}-r${buildNumber}</finalName> 
          ...
        </configuration>
      </plugin>
      ...
    </plugins>