使用maven2将warversion清单添加到war清单中

fen*_*iix 5 java build-automation maven-2 war

我想找到一个maven native(即不调用外部程序)来在war清单中注入svn修订版.

有人知道这样做的方法吗?

我发现提到如何将subversion版本添加到jar文件中的清单,但不包含war文件.

我搜索了SO,但没有具体找到这个问题.

Pas*_*ent 4

我想找到一个maven本机(即不调用外部程序)来将svn修订版注入到war清单中。

这可以通过使用提供程序的Build Number Maven 插件svnjava来实现:

如果您需要在路径中没有任何 svn 的计算机上执行插件,您可以将 mojo 配置为使用 svnjava 提供程序。

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.0-beta-3</version>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>create</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <doCheck>true</doCheck>
          <doUpdate>true</doUpdate>
          <providerImplementations>
            <svn>javasvn</svn>
          </providerImplementations>          
        </configuration>
      </plugin>
    </plugins>
  </build>
Run Code Online (Sandbox Code Playgroud)

构建号 Maven 插件在${buildNumber}属性中设置构建号,然后您可以在 POM 中使用该构建号。

我发现提到如何将 subversion 修订版添加到 jar 文件中的清单中,但不包括 war 文件。

然后,要在 war 的 MANIFEST 中添加内部版本号,请按照“用法”页面中所述配置插件:

  <build>
    ...
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <archive>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
            <manifestEntries>
              <Implementation-Build>${buildNumber}</Implementation-Build>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
Run Code Online (Sandbox Code Playgroud)