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

Adding a timestamp to our bank makes our maven build take ~ 4 times longer than usual. A timestamp is needed to build releases, but it is not needed to create snapshots. How can we configure the POM file only to add TSA arguments when it is the 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 below. We would like them not to 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> 
+6
source share
1 answer

Assuming you are using the maven release plugin for your releases, you can accomplish this by placing the activation profile that it activates from there.

You can also do this with your own profiles if you prefer or don't use the release plugin for 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 leave the TSA argument stuff in the normal part of the build / plugin configuration for jarsigner. If for some reason you wanted the TSA with a snapshot for some reason, you can manually activate the release profile using:

 mvn -Prelease-profile install 
+2
source

All Articles