Maven war manifest entries blank when writing to manifest

696 views Asked by At

I'm trying to add branch and build information to my war's manifest and while the keys show up on the manifest, the values are null. The values I'm pulling from the buildnumber-maven-plugin, and when this plugin executes the log shows the values. I also added a maven-antrun-plugin task to echo the values I'm passing into the war plugin, and they display in the log as well. So I'm having trouble finding out why they are null when writing to the manifest. Here's some examples:

Here's my buildnumber plugin:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.4</version>
            <configuration>
                <doCheck>false</doCheck>
                <doUpdate>false</doUpdate>
            </configuration>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

When this plugin executes I see in the logs..

[INFO] --- buildnumber-maven-plugin:1.4:create (default) @ my-project ---
[INFO] Executing: cmd.exe /X /C "git rev-parse --verify HEAD"
[INFO] Working directory: C:\workspace\my-project
[INFO] Storing buildNumber: 09w3e456df44cd81a5d20f4502f957ae80d52eb2 at timestamp: 1455818030872
[INFO] Storing buildScmBranch: master

Next I just added in a ant task to output these values as well..

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.8</version>
    <executions>
        <execution>
            <phase>generate-resources</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <tasks>
                    <echo>buildNumber: ${buildNumber}</echo>
                    <echo>scmBranch: ${scmBranch}</echo>
                </tasks>
            </configuration>
        </execution>
    </executions>
  </plugin>

And in the logs I see...

[INFO] --- maven-antrun-plugin:1.8:run (default) @ my-project ---
[WARNING] Parameter tasks is deprecated, use target instead
[INFO] Executing tasks

main:
 [echo] buildNumber: 09w3e456df44cd81a5d20f4502f957ae80d52eb2 
 [echo] scmBranch: master

And lastly with the war plugin/archiver, here's where the issue is... Here's the plugin..

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <archive>
                    <manifest>
                        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                    </manifest>
                    <manifestEntries>
                        <sha>${buildNumber}</sha>
                        <branch>${scmBranch}</branch>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>

And here's the resulting manifest where the branch and sha are coming out blank..

Manifest-Version: 1.0
Implementation-Vendor: My Company
sha: 
Implementation-Title: My Project
Implementation-Version: 0.0.1-SNAPSHOT
Implementation-Vendor-Id: com.myproject
Build-Jdk: 1.7.0_79
Built-By: me
branch:
Created-By: Maven Integration for Eclipse
Implementation-URL: [purposely omitted] 

You see that branch and sha are both blank, but in the logs above those values are obviously available. Is something wiping these values out or is there something further required to bubble these values up into the archiver within the maven war plugin?

0

There are 0 answers