Ant overwriting custom manifest file

I am creating a jar with Ant that also uses its own manifest file. The build.xml file creates everything correctly. However, when I check the manifest file in the bank, my properties are gone. It appears to be replaced by the default MANIFEST.MF file created by Ant. My build file is below:

<?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 need to change to specify a custom manifest instead of the default Ant MANIFEST.MF file?

+6
source share
1 answer

I believe the jar ant task has a manifest attribute in which you can specify the actual file to use. In this case, you are referencing a file created using the manifest

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> 
+9
source

Source: https://habr.com/ru/post/913486/


All Articles