35

我想在我的 jar 文件中的清单中添加一个 Implementation-Version 行,以反映 POM 版本号。我一生都无法弄清楚如何使用 jar 插件来做到这一点。

这可能吗?

4

1 回答 1

56

您将使用 Maven 存档器:

<plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
          </manifest>
        </archive>
      </configuration>
    </plugin>
  </plugins>

这会将以下内容添加到清单文件中:

Implementation-Title: ${pom.name}
Implementation-Version: ${pom.version}
Implementation-Vendor-Id: ${pom.groupId}
Implementation-Vendor: ${pom.organization.name}
于 2009-05-28T16:12:22.620 回答