ANT to throw error message

Sometimes we need to manually detect a condition on the user-defined case and throw error messages in ANT. How do we do that?

Let’s take a look at the following example.

<target name="check_1" depends="">
    <available file="abc/def/target_1.js" property="target_1.present"/>
    <fail unless="target_1.present" message="check_1 failed"/>
  1. We detect the existence of a file abc/def/target_1.js and store the checking value to variable target_1.present
  2. If value of target_1.present is false, display message “check_1 failed”


Leave a Reply

Your email address will not be published.