使用 maven 为现有 jar 批量更新 manifest.mf [英] batch updating manifest.mf for existing jars using maven

查看:36
本文介绍了使用 maven 为现有 jar 批量更新 manifest.mf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to add a custom key/value pair to the MANIFEST.MF of several existing jar files in my war project (those jars are not the project dependencies).

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

I already can pack/repack those jars using an ant task.

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

I read about "manifest" task, how can I apply that task to a fileset (if there is a way)? Thanks in advance.

推荐答案

这是我在 StackOverflow 的第一个回答.希望它适合你:)

This is my first answer at StackOverflow. Hope it suits you :)

我是这样做的:

<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 的简单调用:

The call is a simple one using 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 是这样的:

And my custom_manifest.mf is like this:

Trusted-Only: true
Trusted-Library: true

这篇关于使用 maven 为现有 jar 批量更新 manifest.mf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆