Question

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?

Was it helpful?

Solution

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}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top