简体   繁体   English

如何仅在Maven-jarsigner-plugin中的发行版上配置TSA参数

[英]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. 在jar的容器中添加时间戳会使我们的Maven构建花费的时间比平时长约4倍。 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 (ie SNAPSHOT does not appear in the project version). 我们如何将POM文件配置为仅在发行版本(即SNAPSHOT未出现在项目版本中)时添加TSA参数。

Below is our POM entry for the jarsigner plugin. 以下是jarsigner插件的POM条目。 Note the arguments added at the bottom. 请注意在底部添加的参数。 We would like these to not be added if SNAPSHOT appears in the project version: 如果项目版本中出现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>

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. 假设您正在使用Maven发布插件进行发布,则可以通过附带激活它的发布配置文件来实现此目的。

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

Now omit the TSA argument stuff in the normal portion of your build/plugin configuration for the jarsigner. 现在,在jarsigner的构建/插件配置的正常部分中省略TSA参数。 If you happen to want the TSA with a snapshot for some reason you can manually activate the release profile using: 如果由于某种原因碰巧希望TSA带有快照,则可以使用以下方法手动激活发布配置文件:

mvn -Prelease-profile install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM