2

I am trying to get the Mercurial changeSet and changeSetDate set in my MANIFEST.MF file of OSGi bundle using Maven.

I have added the buldnumber-maven-plugin into my pom.xml:

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

And my bundle plugin looks like this:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.7</version>
    <extensions>true</extensions>
    <configuration>
        <archive>
            <manifestEntries>
                <Build-Change-Set>${changeSet}</Build-Change-Set>
                <Build-Change-Set-Date>${changeSetDate}</Build-Change-Set-Date>
                <Build-Location>${basedir}</Build-Location>
                <Build-Machine>${env.COMPUTERNAME}</Build-Machine>
                <Build-Date>${maven.build.timestamp}</Build-Date>
            </manifestEntries>
        </archive>
        <instructions>
            <!-- All imports, exports, etc... -->
        </instructions>
    </configuration>
</plugin>

When I am executing install goal I see that Maven outputs:

[INFO] --- buildnumber-maven-plugin:1.0:hgchangeset (default) @ esb-security ---
[INFO] Setting Mercurial Changeset: 6524595b0389+
[INFO] Setting Mercurial Changeset Date: 2012-09-05 11:38 +0100

But in my MANIFEST.MF I get:

Build-Change-Set: ${changeSet}
Build-Change-Set-Date: ${changeSetDate}

It does not include the values of change set and change set data. Maybe someone know where might be the problem?

Jean-Rémy Revy
  • 5,607
  • 3
  • 39
  • 65
Paulius Matulionis
  • 23,085
  • 22
  • 103
  • 143

2 Answers2

0

Unless maven-bundle-plugin explicitly supports expression variables like ${changeSet}, etc, they won't be resolved by Maven before this plugin execution. So, you may have to use a separate execution of manifest task bound before process-resources phase, and then use Maven's resource filtering support to post-process generated manifest and substitute those variables set by the maven-bundle-plugin.

Eugene Kuleshov
  • 31,461
  • 5
  • 66
  • 67
0

Perhaps if you change the phase for the hgchangeset goal to "initialize" it will occur prior to the Manifest file creation?

Alternatively you can create a stub MF file in your resources folder and use filtering to do the variable substitution, although felix should be able to do this for you.

codefly
  • 11
  • 1