各ファイルを個別にリストしたくない (または簡単にリストできない) 場合、1 つの解決策は、ネストされた<mappedresources>
(Ant 1.8.0+) を許可する Zip タスクを使用することです。Zip タスクが完了すると、Jar タスクを使用してマニフェストを追加/更新したり、インデックスを追加したりできます。
たとえば、欲しいことに加えて、
yay_my.jar
boo_my.jar
foo_my.jar
bar_my.jar
出力 JAR には、stuff/
いくつかのファイルとサブディレクトリを含む directory もあります。のコンテンツをstuff/
JAR に含めたいが、stuff/subdir/*
として追加したい場合other_subdir/*
は、次の点を考慮してください。
<zip destfile="newjar.jar">
<zipfileset dir="yay" includes="my.jar" fullpath="yay_my.jar"/>
<zipfileset dir="boo" includes="my.jar" fullpath="boo_my.jar"/>
<!-- etc. -->
<mappedresources>
<fileset dir="stuff"/>
<compositemapper>
<globmapper from="subdir/*" to="other_subdir/*"/>
<identitymapper/>
</compositemapper>
</mappedresources>
</zip>
<!-- Update the newly-created ZIP in-place to add a basic manifest -->
<jar destfile="newjar.jar" update="true"/>
このビルド ファイルをテストしたところ、Ant 1.8.2 で動作します。ただし、変更後に Ant が をスローし始めた場合は、 Bug 54026NullPointerException
を参照してください。