0

使用buildnumbermaven 插件,我想获取存储在我的 jar 清单中的分支。我尝试了两种不同的方法,如下所示。

这是我构建的输出(仅相关部分) [INFO] --- buildnumber-maven-plugin:1.4:create (default) @ myproject --- [INFO] ShortRevision tag detected. The value is '7'. [INFO] Executing: /bin/sh -c cd '/workspace/myproject' && 'git' 'rev-parse' '--verify' '--short=7' 'HEAD' [INFO] Working directory: /workspace/myproject [INFO] Storing buildNumber: ed5ea17 at timestamp: 1479511476753 [INFO] Storing buildScmBranch: bug/abuginthesystem

这里是尝试 1 的插件部分(来自插件网站的 SCMBranch 密钥): <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>buildnumber-maven-plugin</artifactId> <version>1.4</version> <executions> <execution> <phase>validate</phase> <goals> <goal>create</goal> </goals> </execution> </executions> <configuration> <doCheck>false</doCheck> <doUpdate>false</doUpdate> <shortRevisionLength>7</shortRevisionLength> </configuration> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <configuration> <archive> <manifestEntries> <Build-OS>${os.name} ${os.version}</Build-OS> <Build-Java>Java ${java.version}</Build-Java> <Build-Number>${buildNumber}</Build-Number> <Build-Branch>${SCMBranch}</Build-Branch> </manifestEntries> </archive> </configuration> </plugin>

尝试 2 使用构建: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>buildnumber-maven-plugin</artifactId> <version>1.4</version> <executions> <execution> <phase>validate</phase> <goals> <goal>create</goal> </goals> </execution> </executions> <configuration> <doCheck>false</doCheck> <doUpdate>false</doUpdate> <shortRevisionLength>7</shortRevisionLength> </configuration> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <configuration> <archive> <manifestEntries> <Build-OS>${os.name} ${os.version}</Build-OS> <Build-Java>Java ${java.version}</Build-Java> <Build-Number>${buildNumber}</Build-Number> <Build-Branch>${buildScmBranch}</Build-Branch> </manifestEntries> </archive> </configuration> </plugin>

两者的清单输出是: Manifest-Version: 1.0 Build-Java: Java 1.7.0_79 Build-Number: ed5ea17 Build-OS: Linux 4.4.0-47-generic Built-By: mondain Build-Jdk: 1.7.0_79 Build-Branch: Created-By: Apache Maven 3.3.9 Archiver-Version: Plexus Archiver

4

1 回答 1

2

如果你想在你的manifestEntries:

<Build-Branch>${buildScmBranch}</Build-Branch>

然后,您应该在配置中使用以下内容buildnumber-maven-plugin

<plugin>
    <artifactId>buildnumber-maven-plugin</artifactId>
  ...
    <configuration>
        <scmBranchPropertyName>buildScmBranch</scmBranchPropertyName>
      ...
于 2016-11-19T09:03:55.470 回答