2013-04-17 80 views
2

我想在我的戰爭項目中的幾個現有jar文件的MANIFEST.MF中添加一個自定義鍵/值對(這些罐子不是項目依賴關係)。使用maven爲現有罐子批量更新manifest.mf

我已經可以使用螞蟻任務打包/重新包裝這些罐子。

我讀過關於「清單」任務,我該如何將該任務應用到文件集(如果有方法)?提前致謝。

回答

3

這是我在StackOverflow的第一個答案。希望它適合你:)

我已經做了這樣的:

<target name="xxx.modifyManifests"> 
    <echo message="Modifying jar manifests to add trusted-library" /> 
    <apply executable="jar"> 
     <arg value="umf" /> 
     <arg line="${xxx.resources}/manifest/custom_manifest.mf" /> 
     <srcfile /> 
     <fileset dir="${xxx.target}/applets" includes="*.jar" /> 
    </apply> 
</target> 

的調用是一個簡單的使用maven-antrun-插件:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>xxx.modifyManifests</id> 
      <phase>compile</phase> 
      <configuration> 
       <target> 
        <property environment="windows" /> 
        <property name="xxx.resources" 
         value="${project.build.directory}/../src/main/resources" /> 
        <property name="xxx.target" 
         value="${project.build.directory}/${project.artifactId}-${project.version}" /> 
        <ant antfile="${basedir}/build.xml"> 
         <target name="xxx.modifyManifests" /> 
        </ant> 
       </target> 
      </configuration> 
      <goals> 
       <goal>run</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

而且我custom_manifest.mf是這樣的:

Trusted-Only: true 
Trusted-Library: true 
+0

非常感謝你的同事!在你的幫助下,我的戰爭項目現在已經有了pack.gz +簽名+值得信賴的依賴關係的applet! :d – Gabriel