使用maven批量更新现有jar的manifest.mf

时间:2013-04-17 16:40:09

标签: maven ant

我想在我的war项目中的几个现有jar文件的MANIFEST.MF中添加一个自定义键/值对(这些jar不是项目依赖项)。

我已经可以使用ant任务打包/重新包装这些罐子了。

我读到了“清单”任务,如何将该任务应用于文件集(如果有办法)?提前谢谢。

1 个答案:

答案 0 :(得分: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进行简单的调用:

<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