views:

991

answers:

1

I'd like to add an Implementation-Version line to a manifest in my jar file that reflects the POM version number. I can't for the life of me work out how to do this using the jar plugin.

Is this possible?

+3  A: 

You would use the Maven Archiver:

<plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
          </manifest>
          <manifestEntries>
            <Implementation-Build>${buildNumber}</Implementation-Build>
          </manifestEntries>
        </archive>
      </configuration>
    </plugin>
  </plugins>

This will add the following to the manifest file:

Implementation-Title: ${pom.name}
Implementation-Version: ${pom.version}
Implementation-Vendor-Id: ${pom.groupId}
Implementation-Vendor: ${pom.organization.name}
Ascalonian
${buildNumber}? How about this variable?
dfa
Sorry, that wasn't needed. I was just showing other Implementation values to set.
Ascalonian
Thanks for the help!
izb
Anytime! I have run into this issue before so I am just glad I can share what I learned with someone else :-)
Ascalonian