<project default="compile">

    <target name="clean">
        <delete dir="build"/>
    </target>

    <target name="compile">
        <subant buildpath="../../java"/>
        <mkdir dir="build"/>
        <javac debug="true" srcdir="." destdir="build" source="1.8" target="1.8">
            <classpath>
                <pathelement path="../../java/sodium/sodium.jar"/>
            </classpath>
        </javac>
    </target>

    <target name="run">
        <java classname="pump.PetrolPump" fork="true">
            <classpath>
                <pathelement path="build/"/>
                <pathelement path="../../java/sodium/sodium.jar"/>
            </classpath>
        </java>
    </target>

</project>

<project default="compile">

    <target name="clean">
        <delete dir="build"/>
    </target>

    <target name="compile">
        <subant buildpath="../../java"/>
        <mkdir dir="build"/>
        <javac debug="true" srcdir="." destdir="build" source="1.8" target="1.8">
            <classpath>
                <pathelement path="../../java/sodium/sodium.jar"/>
            </classpath>
        </javac>
    </target>

    <target name="run" depends="compile">
        <java classname="pump.PetrolPump" fork="true">
            <classpath>
                <pathelement path="build/"/>
                <pathelement path="../../java/sodium/sodium.jar"/>
            </classpath>
        </java>
    </target>

</project>

Make 'ant run' depend on 'ant compile' for petrol pump
Make 'ant run' depend on 'ant compile' for petrol pump
