<?xml version="1.0" encoding="UTF-8"?>
<project name="Check README">
    <property name="executable.rst" location="/usr/bin/rst2html" />

    <target name="readme" extensionOf="-package:main~hook">
        <exec executable="${executable.rst}" failonerror="true" dir="${basedir}" errorproperty="readme.error">
            <arg value="${basedir}/README.rst" />
            <arg value="${builddir}/README.html" />
        </exec>

        <fail>
            <condition>
                <not>
                    <equals arg1="${readme.error}" arg2=""/>
                </not>
            </condition>
            The README.rst contains errors:
            ${readme.error}
        </fail>
    </target>
</project>

<?xml version="1.0" encoding="UTF-8"?>
<project name="Check README">
    <property name="executable.rst" location="/usr/bin/rst2html" />

    <target name="-readme:check-exec">
        <available file="${executable.rst}" type="file" property="readme:exec:available"/>
    </target>

    <target name="readme" depends="-readme:check-exec" extensionOf="-package:main~hook" if="readme:exec:available">
        <exec executable="${executable.rst}" failonerror="true" dir="${basedir}" errorproperty="readme.error">
            <arg value="${basedir}/README.rst" />
            <arg value="${builddir}/README.html" />
        </exec>

        <fail>
            <condition>
                <not>
                    <equals arg1="${readme.error}" arg2=""/>
                </not>
            </condition>
            The README.rst contains errors:
            ${readme.error}
        </fail>
    </target>
</project>

Check README only if tool exists
Check README only if tool exists
