7

Adding a timestamp to our jar's causes our maven build to take ~4 times longer than usual. Timestamp is necessary for release builds, but we don't need it for snapshot builds. How would we configure the POM file to only add the TSA arguments when it is a Release version (i.e. SNAPSHOT does not appear in the project version).

Below is our POM entry for the jarsigner plugin. Note the arguments added at the bottom. We would like these to not be added if SNAPSHOT appears in the project version:

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jarsigner-plugin</artifactId>
          <version>1.2</version>
          <executions>
            <execution>
              <id>sign webcontent jars</id>
              <phase>prepare-package</phase>
              <goals>
                <goal>sign</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <archiveDirectory>${project.build.directory}/projectname-webcontent/applets</archiveDirectory>
            <includes>
              <include>*.jar</include>
            </includes>
            <keystore>Keystore</keystore>
            <alias>alias</alias>
            <storepass>pass</storepass>
            <arguments>
              <argument>-tsa</argument>
              <argument>https://timestamp.geotrust.com/tsa</argument>
            </arguments>
          </configuration>
        </plugin>
4

1 回答 1

3

假设您使用 maven 发布插件进行发布,您可以通过捎带它激活的发布配置文件来完成此操作。

如果您喜欢或不使用发布插件进行发布,您也可以使用自己的自定义配置文件来执行此操作。

在您的 pom 中,您将包括:

<profiles>
    <profile>
        <id>release-profile</id>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jarsigner-plugin</artifactId>
            ...
            <!-- Put your configuration with the TSA here -->
        </plugin>
    </profile>
</profiles>

现在省略 jarsigner 的构建/插件配置的正常部分中的 TSA 参数内容。如果您出于某种原因碰巧想要带有快照的 TSA,您可以使用以下方法手动激活发布配置文件:

mvn -Prelease-profile install
于 2013-11-14T17:05:24.247 回答