I have the following Ant target :
<target name="getArchiverStatus" depends="exportContent">
<java classname="com.test.cms.build.GetErrorCountForArchiver" failonerror="true">
<classpath>
<pathelement location="${cs.home}/${env}/main/main.jar" />
<fileset dir="${cs.home}/${env}/lib" includes="*.jar" />
</classpath>
<arg value="${cs.url}" />
<arg value="${cs.username}" />
<arg value="${cs.password}" />
<arg value="${ucm.archive.name}" />
<arg value="${ucm.workflow.logs.dir}" />
</java>
</target>
I want that this particular target should fail terminating further execution of the build file when the java class GetErrorCountForArchiver has thrown an Exception.Even after using Failonerror= true the next target is getting executed...
Make sure you use the fork=true and failonerror=true. I was running into the same issue but after having those two properties set I got it working as I wanted.
I had simple class
Then a simple ant build file
clean-build and main do not run because the run target fails due to the exception thrown by the main class. Notice that the following line is the one that does the trick in the run target
When I execute ant this is what I get