Here's a sample I created. This has two jar tasks: jar and jar1. One uses the if check and the other the unless check. The ant target 'all' calls both, but only 1 should run. It checks if the manifest file exsts and if so uses that file, otherwise you can create a local in the jar1 task.
If you want to have only the 1 jar target, then you may need to use the Ant-Contrib tasks and use the tag. Here is a good link to review for this too.
<project name="StackOverflow" basedir="." default="all">
<property name="src.dir" value="${basedir}/src"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<target name="all" depends="compile,jar,jar1"/>
<target name="check-manifest">
<available file="META-INF/MANIFEST.MF" property="manifest.present"/>
</target>
<target name="jar" depends="check-manifest" if="manifest.present">
<echo>Using existing manifest.mf</echo>
<jar destfile="hello.jar" manifest="META-INF/MANIFEST"/>
</target>
<target name="jar1" depends="check-manifest" unless="manifest.present">
<echo>creating local manifest</echo>
<jar destfile="hello.jar">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Permissions" value="all-permissions"/>
<attribute name="Codebase" value="*"/>
</manifest>
<fileset dir="${classes.dir}">
<include name="**/*.*"/>
</fileset>
</jar>
</target>
</project>