Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:27:05+00:00 2026-06-08T04:27:05+00:00

Can someone please explain me with Example of Ant condition property with if, and,

  • 0

Can someone please explain me with Example of Ant condition property with “if”, “and”, “not” and “istrue” with the code??

I’m new to Ant and need help on this.

Basically i need to download file using FTP. I have code to download it. but there are few condition i need to check before downloading.

  1. Before downloading check the Downloadstatusvariable value (usually its true or false value”)
  2. check whether file is already downloaded or available in the path
  3. if both the conditions fails then exec the FTP download code.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:27:08+00:00Added an answer on June 8, 2026 at 4:27 am

    ant-contrib is widely-used library and the if/else/for/foreach tasks will not only make it easier to write complex ant scripts, they’ll make your ant scripts much more readable.

    But, since you insist 🙂

    The way I’ve handled this in the past is to set up a task A that only executes if property X is set, and make task A depend on some task B that checks the conditions and sets property X if they are true. For example:

    <target name="get-ftp-file" depends="check-need-ftp-file" if="ftp.call.required">
      <ftp ... />
    </target>
    
    <target name="check-need-ftp-file">
      <condition property="ftp.call.required">
        <and>
          <not>
            <!-- Checks if Downloadstatusvariable variable is true -->
            <istrue value="${Downloadstatusvariable}"/>
          </not>
          <not>
            <!-- Checks if file is present in filesystem -->
            <available file="${my.file}"/>
          </not>
        </and>
      </condition>
    </target>
    

    EDIT:

    coolgokul, the <and> and <not> tasks are standard logical operators. The <available> condition in the example above evaluates to true if the file exists on the local machine. But we want to download the file only if the file does NOT exist on the local machine, so we wrap it up in the <not> task. Similar for the ${Downloadstatusvariable} check–we want to make sure it is not true, so we use <istrue> and then wrap it up in <not>.

    Finally, we want to make sure that that the variable is not true AND the file does not exist, so we wrap up both those conditions in <and>. Translated to English, we’re asking “Is Downloadstatusvariable not true, and is the downloaded file not available?”

    Recommend you read more about conditional operators @ http://ant.apache.org/manual/Tasks/conditions.html

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain me why we need nested locking ? look at this
Can someone please explain with example that I can understand about the difference between
Can someone please explain to me how this responsive approach works? This was done
Can someone please explain this phenomenon? I am using Mojarra 2.1.6 - Glassfish 3.1.2.
can someone please explain to me the following JavaScript design pattern example and what
Can someone please explain why pointers aren't initialized to NULL ? Example: void test(){
Obviously I'm new to as3...Can someone please explain to me how I can use
Can someone please explain why is meta class used in the following example. Ex:
For Chaining: Can someone please explain this concept to me and provide me a
If this is the best (or a good) solution, can someone please explain exactly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.