如何使用Maven将实现版本值添加到jar清单?

izb*_*izb 26 java build-process maven-2 jar manifest

我想将一个Implementation-Version行添加到我的jar文件中反映POM版本号的清单.我不能为我的生活找出如何使用jar插件做到这一点.

这可能吗?

Asc*_*ian 41

你会使用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>
Run Code Online (Sandbox Code Playgroud)

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

Implementation-Title: ${pom.name}
Implementation-Version: ${pom.version}
Implementation-Vendor-Id: ${pom.groupId}
Implementation-Vendor: ${pom.organization.name}
Run Code Online (Sandbox Code Playgroud)

  • 有没有办法用单线属性做到这一点?我想知道它是否以类似的方式工作:`&lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;` (2认同)