Mik*_*e B 6 java jarsigner pom.xml maven
在我们的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)
小智 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>
Run Code Online (Sandbox Code Playgroud)
现在,在 jarsigner 的构建/插件配置的正常部分中省略 TSA 参数内容。如果由于某种原因您碰巧需要 TSA 快照,您可以使用以下命令手动激活发布配置文件:
mvn -Prelease-profile install
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2204 次 |
| 最近记录: |