【问题标题】:How do I add an Implementation-Version value to a jar manifest using Maven?如何使用 Maven 将 Implementation-Version 值添加到 jar 清单?
【发布时间】:2010-10-29 15:08:30
【问题描述】:

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

这可能吗?

【问题讨论】:

    标签: java maven-2 build-process jar manifest


    【解决方案1】:

    您将使用 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}
    

    【讨论】:

    • ${buildNumber}?这个变量怎么样?
    • 抱歉,不需要。我只是显示要设置的其他实现值。
    • 随时!我以前遇到过这个问题,所以我很高兴可以与其他人分享我学到的东西:-)
    • 使其适用于 EAR:&lt;artifactId&gt;maven-ear-plugin&lt;/artifactId&gt;
    • 有没有办法用单线属性做到这一点?我想知道它是否以类似的方式工作:&lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
    猜你喜欢
    • 2010-10-29
    • 2012-02-18
    • 2019-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多