2013-01-04 54 views
6

將時間戳添加到我們的jar中會導致我們的maven構建比平常長4倍。時間戳是發佈版本所必需的,但我們不需要它來進行快照構建。我們如何將POM文件配置爲只在發佈版本時添加TSA參數(即,SNAPSHOT未出現在項目版本中)。如何在maven-jarsigner-plugin中的發行版中僅配置TSA參數

下面是我們的jsigner插件的POM條目。注意底部添加的參數。我們希望這些不被添加如果快照在項目中出現的版本:

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

回答

2

假設你正在使用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> 

現在省略TSA爭論的東西在你的編譯/插件配置爲的jarsigner的正常部分。如果您因爲某些原因想要使用快照的TSA,則可以使用以下方法手動激活發佈配置文件:

mvn -Prelease-profile install 
相關問題