0

我正在尝试将分支和构建信息添加到我的战争清单中,虽然清单上显示了键,但值为空。我从 buildnumber-maven-plugin 中提取的值,当这个插件执行时,日志会显示这些值。我还添加了一个 maven-antrun-plugin 任务来回显我传递给 war 插件的值,它们也会显示在日志中。因此,在写入清单时,我很难找出为什么它们为空。这里有一些例子:

这是我的内部版本号插件:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.4</version>
            <configuration>
                <doCheck>false</doCheck>
                <doUpdate>false</doUpdate>
            </configuration>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

当这个插件执行时,我在日志中看到..

[INFO] --- buildnumber-maven-plugin:1.4:create (default) @ my-project ---
[INFO] Executing: cmd.exe /X /C "git rev-parse --verify HEAD"
[INFO] Working directory: C:\workspace\my-project
[INFO] Storing buildNumber: 09w3e456df44cd81a5d20f4502f957ae80d52eb2 at timestamp: 1455818030872
[INFO] Storing buildScmBranch: master

接下来我刚刚添加了一个 ant 任务来输出这些值。

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.8</version>
    <executions>
        <execution>
            <phase>generate-resources</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <tasks>
                    <echo>buildNumber: ${buildNumber}</echo>
                    <echo>scmBranch: ${scmBranch}</echo>
                </tasks>
            </configuration>
        </execution>
    </executions>
  </plugin>

在我看到的日志中......

[INFO] --- maven-antrun-plugin:1.8:run (default) @ my-project ---
[WARNING] Parameter tasks is deprecated, use target instead
[INFO] Executing tasks

main:
 [echo] buildNumber: 09w3e456df44cd81a5d20f4502f957ae80d52eb2 
 [echo] scmBranch: master

最后是战争插件/存档器,这就是问题所在......这是插件......

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <archive>
                    <manifest>
                        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                    </manifest>
                    <manifestEntries>
                        <sha>${buildNumber}</sha>
                        <branch>${scmBranch}</branch>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>

这是生成的清单,其中分支和 sha 出现空白..

Manifest-Version: 1.0
Implementation-Vendor: My Company
sha: 
Implementation-Title: My Project
Implementation-Version: 0.0.1-SNAPSHOT
Implementation-Vendor-Id: com.myproject
Build-Jdk: 1.7.0_79
Built-By: me
branch:
Created-By: Maven Integration for Eclipse
Implementation-URL: [purposely omitted] 

您会看到branchsha都是空白的,但在上面的日志中,这些值显然是可用的。是否有什么东西会清除这些值,或者是否需要进一步将这些值冒泡到 maven 战争插件中的存档器中?

4

0 回答 0