Søk i denne bloggen

fredag 9. september 2011

Using maven buildnumber plugin tool to insert build number into the jar manifest.



Add the following script to your branding pom


    <scm>
        <connection>scm:svn:<svnurl></connection>
        <url><svnurl></url>
    </scm>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <phase>validate</phase>        
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doCheck>false</doCheck>
                    <doUpdate>true</doUpdate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <useDefaultManifestFile>true</useDefaultManifestFile>
                    <archive>
                        <manifestEntries>
                            <Implementation-Build>${prog.version}.${buildNumber}</Implementation-Build>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

The ${prog.version} can be applied in the parent pom's properties as i.e. 1.0. The ${buildnumber} is fetched from the svn using revision head number, hence the scm tag is required. The result is that the property Implementation-Build:<buildnumber> is appended to the branding modules meta-inf/manifest.mf. 
If you want to use the manifest property in the application (i.e in a title), read this 

Ingen kommentarer:

Legg inn en kommentar