在我们的jar中添加一个时间戳会导致我们的maven构建比平常花费大约4倍.时间戳是发布版本所必需的,但我们不需要它来进行快照构建.我们如何将POM文件配置为仅在发布版本时添加TSA参数(即SNAPSHOT未出现在项目版本中).
下面是jarsigner插件的POM条目.请注意底部添加的参数.如果SNAPSHOT出现在项目版本中,我们希望不添加这些:
<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>
Run Code Online (Sandbox Code Playgroud)