Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add subversion revision to war manifest using maven2

I want to find a maven native (i.e. without calling external programs) to inject the svn revision in the war manifest.

Does anybody know a way to do that?

I found mention to how to add the subversion revision to manifests in jar files but not with war files.

I searched SO but could not find this issue specifically.

like image 954
feniix Avatar asked Jun 02 '10 21:06

feniix


1 Answers

I want to find a maven native (i.e. without calling external programs) to inject the svn revision in the war manifest.

This is possible with the Build Number Maven Plugin using the svnjava provider:

If you need to execute the plugin on machine without any svn in the path you can configure the mojo to use the svnjava provider.

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

The Build Number Maven Plugin sets the build number in the ${buildNumber} property that you can then use in your POM.

I found mention to how to add the subversion revision to manifests in jar files but not with war files.

Then, to add the build number in the MANIFEST of a war, configure the plugin as mentioned in the Usage page:

  <build>
    ...
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <archive>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
            <manifestEntries>
              <Implementation-Build>${buildNumber}</Implementation-Build>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
like image 129
Pascal Thivent Avatar answered Sep 25 '22 01:09

Pascal Thivent