zip ファイルと複数の JAR ファイルのマニフェストを作成する Ant ファイルがあります。zip とマニフェストはどちらも同じライブラリを参照していますが、その方法はわずかに異なります。可能であれば、ファイルへの参照を明示的に2回書き込んで両方のタスクの参照が同期するのではなく、ファイルへの参照を結合したいと考えています。以下は、私が現在行っていることの例です。
<target name="zip" depends="default">
<zip destfile="${dist.dir}/${project.name}_v${project.version}.zip">
<zipfileset prefix="lib" dir="lib/Dom4J" includes="*.jar"/>
<zipfileset prefix="lib" dir="lib/GSON" includes="*.jar"/>
<zipfileset prefix="lib" dir="lib/Guava" includes="*.jar"/>
<!-- ... A bunch more (Note I don't want everything
in the lib directory, just certain subfolders
within the lib directory which are explicitly
listed here like GSON. -->
</zip>
</target>
<target name="createManifest">
<!-- Hard code the classpath by hand and hope
they sync up with the zip task -->
<property name="mfClasspath"
value="dom4j-1.6.1.jar gson-2.1.jar guava-11.0.2.jar" />
<!-- Code to use the mfClasspath when creating the manifest
omitted for brevity -->
</target>
私が理想的に持ちたいのはfileset
、両方のタスクで参照できるようなものです。マニフェストにはフォルダー/パスが含まれていないことに注意してください。マニフェストには、タスクで言及されたディレクトリ内にある JAR ファイルのみが含まれzip
ます。