且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 Ant 将文件复制到现有 JAR 中?

更新时间:2023-02-03 15:53:12

Jar/Ear Ant 任务是更通用的 Zip 任务.这意味着您还可以在 Jar 任务中使用 zipfileset:

The Jar/Ear Ant tasks are subtasks of the more general Zip task. This means that you can also use zipfileset in your Jar task:

<jar destfile="${jar.file}" basedir="...">
    <zipfileset dir="${project.path}" includes="*.jar" prefix="libs"/>
</jar>

我还看到您定义了一个单独的清单文件以包含在 Jar 中.您还可以使用嵌套的 manifest 命令:

I've also seen that you define a separate manifest file for inclusion into the Jar. You can also use a nested manifest command:

<jar destfile="@{destfile}" basedir="@{basedir}">
    <manifest>
        <attribute name="Built-By" value="..."/>
        <attribute name="Built-Date" value="..."/>

        <attribute name="Implementation-Title" value="..."/>
        <attribute name="Implementation-Version" value="..."/>
        <attribute name="Implementation-Vendor" value="..."/>
    </manifest>
</jar>