eclipse Ant 覆盖自定义清单文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10202447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ant overwritting custom manifest file
提问by Jason
I am creating a jar with Ant that also uses a custom manifest file. The build.xml file builds everything properly. However, when I check the manifest file in the jar, my properties are not there. It looks like it is being replaced with the default MANIFEST.MF file built by Ant. My build file is below:
我正在用 Ant 创建一个 jar,它也使用自定义清单文件。build.xml 文件正确构建所有内容。但是,当我检查 jar 中的清单文件时,我的属性不存在。看起来它正在被 Ant 构建的默认 MANIFEST.MF 文件替换。我的构建文件如下:
<?xml version="1.0" ?>
<property name="src" location="src" />
<property name="build" location="build" />
<property name="dist" location="dist" />
<target name="clean">
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
<target name="main" depends="compile, dist, build">
<echo>
Building the .jar file.
</echo>
</target>
<target name="build">
<mkdir dir="${build}" />
<mkdir dir="${build}/META-INF" />
</target>
<target name="compile" depends="build">
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="dist" depends="compile">
<mkdir dir="${dist}/lib" />
<manifest file="${build}/META-INF/MANIFEST.MF">
<attribute name="Class-Path" value="MyGame.jar" />
<attribute name="Main-Class" value="game.Game"/>
</manifest>
<jar jarfile="${dist}/lib/MyGame.jar" basedir="${build}" />
</target>
What do I have to change to specify the custom manifest instead of the default Ant MANIFEST.MF file?
我必须更改什么才能指定自定义清单而不是默认的 Ant MANIFEST.MF 文件?
回答by Doug Ayers
I believe the jar ant task has a manifest attribute where you can specify the actual file to use. In this case you'd reference the file you created with the manifest task
我相信 jar ant 任务有一个 manifest 属性,您可以在其中指定要使用的实际文件。在这种情况下,您将引用您使用清单任务创建的文件
http://ant.apache.org/manual/Tasks/jar.html
http://ant.apache.org/manual/Tasks/jar.html
<target name="dist" depends="compile">
<mkdir dir="${dist}/lib" />
<manifest file="${build}/META-INF/MANIFEST.MF">
<attribute name="Class-Path" value="MyGame.jar" />
<attribute name="Main-Class" value="game.Game"/>
</manifest>
<jar manifest="${build}/META-INF/MANIFEST.MF" jarfile="${dist}/lib/MyGame.jar" basedir="${build}" />
</target>