如何让分支进入清单
How to get branch into manifest
使用 buildnumber
maven 插件,我想将分支存储在我的 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
如果您想在 manifestEntries
中使用以下内容:
<Build-Branch>${buildScmBranch}</Build-Branch>
那么你应该在 buildnumber-maven-plugin
的配置中使用以下内容:
<plugin>
<artifactId>buildnumber-maven-plugin</artifactId>
...
<configuration>
<scmBranchPropertyName>buildScmBranch</scmBranchPropertyName>
...
使用 buildnumber
maven 插件,我想将分支存储在我的 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
如果您想在 manifestEntries
中使用以下内容:
<Build-Branch>${buildScmBranch}</Build-Branch>
那么你应该在 buildnumber-maven-plugin
的配置中使用以下内容:
<plugin>
<artifactId>buildnumber-maven-plugin</artifactId>
...
<configuration>
<scmBranchPropertyName>buildScmBranch</scmBranchPropertyName>
...