3

I have an ANT build file which has the line-

<java classname="arq.sparql" fork="true" outputproperty="javaresult" errorproperty="javaerror">

Now I want add the condition to fail the build of the property 'javaerror' is not empty. So I have the condition written like this :

<fail message="${javaerror}">
 <condition>
  <not>
   <equals javaerror=""/>
  </not>
</condition>
</fail>

But this did not work, can you please help.

Kind regards Som

Rebse
  • 10,307
  • 2
  • 38
  • 66
Som Sarkar
  • 289
  • 1
  • 5
  • 24

2 Answers2

6

Your equals condition has the wrong syntax, it will work like that :

  <fail message="${javaerror}">
   <condition>
    <not>
     <equals arg1="${javaerror}" arg2=""/>
    </not>
  </condition>
  </fail>

see Ant manual conditions for details
-- EDIT --
Alternatively you could use the new if/unless feature introduced with Ant 1.9.1 but you should use Ant 1.9.3 because of bugs in Ant 1.9.1 see this answer for details

<project xmlns:if="ant:if" xmlns:unless="ant:unless">

 <property name="javaerror" value="whatever"/>

 <fail message="${javaerror}" unless:blank="${javaerror}"/>

</project>
Community
  • 1
  • 1
Rebse
  • 10,307
  • 2
  • 38
  • 66
3

You're looking for

<fail message="failed" if="javaerror"/>

Fail ant task doc

Alex
  • 10,470
  • 8
  • 40
  • 62
  • This will also fail if javaerror="" means it will fail as soon as ${javaerror} is set but it should only fail if ${javaerror} != "" – Rebse Feb 10 '14 at 17:27