0
votes

I have a ANT build.xml file which goes like this-

<?xml version="1.0"?>
<project name="apache-jena-2.10.0" basedir="." default="notifyme">
 <target name="notifyme">
  <java classname-"arq.sparql" fork="true">
   <arg value="--data=C:\apache-jena-2.10.0\test.ttl"/>
   <arg value="--query=C:\apache-jena-2.10.0\ASKTest.rq"/>
   <jvmarg value="-Xmx1024M"/>
   <classpath>
    <path>
      <fileset dir="lib">
       <include name="*.jar"/>
      </fileset>
   </path>
  </classpath>
 </java>
</target>
</project>

This build.xml basically run a query and return a specefic result. The result comes like this-

notifyme:
         [java] Ask =>No
BUILD SUCCESSFUL
Total time : 1second

Now my question is there any way I can make the build fail if Ask => No, if yes can any one please help me to customise the ANT build file.

Kind regards Som

1

1 Answers

1
votes

Use the resultproperty attribute for java task. It will store standard out in the given property. Then us the fail task, with conditions task:

<?xml version="1.0"?>
<project name="apache-jena-2.10.0" basedir="." default="notifyme">
 <target name="notifyme">
  <java classname-"arq.sparql" fork="true" failonerror="false" outputproperty="javaresult">
   <arg value="--data=C:\apache-jena-2.10.0\test.ttl"/>
   <arg value="--query=C:\apache-jena-2.10.0\ASKTest.rq"/>
   <jvmarg value="-Xmx1024M"/>
   <classpath>
    <path>
      <fileset dir="lib">
       <include name="*.jar"/>
      </fileset>
   </path>
  </classpath>
 </java>
 <fail>
   <condition>
      <matches string="${javaresult} pattern="No"/>
   </condition>
 </fail>
</target>
</project>

Did not test it. But you can get the idea.