1

Currently I have this code in ant script:

<target name="-pre-compile" if="${log.disabled}">
   <antcall target="remove-logs"/>
</target>

It's pretty self explanatory: if log.disable=true in properties file, then my remove-logs target will be called. Now I need to make minor changes to if/else. Pseudo-code:

<target name="-pre-compile">
   if("${log.disabled}")
      <antcall target="remove-logs"/>
   else if("${log.disabled.level}" != "")
      <antcall target="remove-logs-levels"/>
</target>

how can I write that in ant?

Also, note that all these if/them ant-contrib do not work for me:

<target name="test-xxx">
    <echo level="info">testing</echo>
    <if>
     <equals arg1="${log.disabled}" arg2="true" />
     <then>
       <echo message="true" />
     </then>
     <else>
       <echo message="false" />
     </else>
    </if>
</target>

get's me this output:

custom_rules.xml:73: if doesn't support the nested "equals" element.

PS. Once again, I ended up writing javascript instead of wasting time with ant itself. What a crappy make replacement...

Pavel P
  • 15,789
  • 11
  • 79
  • 128
  • possible duplicate of [ant-contrib - if/then/else task](http://stackoverflow.com/questions/5116619/ant-contrib-if-then-else-task) – Jayan May 04 '14 at 05:27
  • @Jayan doesn't work for me anything that's listed there. It's just insane that simple if else takes forever to figure out how to do. – Pavel P May 04 '14 at 06:07

1 Answers1

0

Ant provide conditionals. Frankly using ant-contrib is easier. It provides an if task. See a more detailed answer in ant-contrib - if/then/else task

Community
  • 1
  • 1
Jayan
  • 18,003
  • 15
  • 89
  • 143
  • What bout checking that a property is defined and it's not an empty string? (I updated the title) – Pavel P May 04 '14 at 05:35