How do I add an Implementation-Version value to a jar manifest using Maven?

26,229

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>
        </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}
Share:
26,229
izb
Author by

izb

Twitter: http://twitter.com/izb

Updated on May 11, 2020

Comments

  • izb
    izb almost 4 years

    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?

  • dfa
    dfa almost 15 years
    ${buildNumber}? How about this variable?
  • Ascalonian
    Ascalonian almost 15 years
    Sorry, that wasn't needed. I was just showing other Implementation values to set.
  • Ascalonian
    Ascalonian almost 15 years
    Anytime! I have run into this issue before so I am just glad I can share what I learned with someone else :-)
  • DagR
    DagR over 11 years
    To make it work for an EAR: <artifactId>maven-ear-plugin</artifactId>
  • Brad Turek
    Brad Turek over 6 years
    Is there a way to do this with a one-liner property? I'm wondering if it works in a similar way to: <maven.compiler.target>1.8</maven.compiler.target>