Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure TSA argument only on release in maven-jarsigner-plugin

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>
like image 544
Mike B Avatar asked Jan 04 '13 21:01

Mike B


1 Answers

Assuming you are using the maven release plugin for your releases, you can accomplish this by piggy-backing off the release profile that it activates.

You could also do this with your own custom profiles if you prefer or are not using the release plugin to do your releases.

In your pom, you would include:

<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>

Now omit the TSA argument stuff in the normal portion of your build/plugin configuration for the jarsigner. If you happen to want the TSA with a snapshot for some reason you can manually activate the release profile using:

mvn -Prelease-profile install
like image 149
nerdlinger Avatar answered Sep 16 '22 12:09

nerdlinger