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 576787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:05:03+00:00 2026-05-13T14:05:03+00:00

My question is similar to avoiding-re-building-prerequisites-in-ant , except that my need doesn’t involve created

  • 0

My question is similar to avoiding-re-building-prerequisites-in-ant, except that my need doesn’t involve created objects, but processes invoked, so the solutions discussed there won’t work for me. At least I think so – but I’m new to ant.

My situation is that I’m writing a set of ant targets, and I need the lets-call-it setup target to be executed once and only once, no matter which target is invoked. Here’s a greatly simplified example:


    <?xml version="1.0"?>
    <project name="Ant_Test" basedir=".">
      <target name="setup">
        <echo message="In setup" />
      </target>
      <target name="do.several" depends="setup">
        <echo message="In do.several, calling do.first" />
        <antcall target="do.first" />
        <echo message="In do.several, calling do.second" />
        <antcall target="do.second" />
      </target>
      <target name="do.first" depends="setup">
        <echo message="In do.first" />
      </target>
      <target name="do.second" depends="setup">
        <echo message="In do.second" />
      </target>
    </project>

I need setup to be invoked exactly once, regardless of whether do.several, do.first, or do.second are invoked. With my naive attempt above, invoking do.several results in three calls to setup.

I’ve thought of setting a property (let’s call it setup.has.been.invoked), and using that to conditionally invoke setup from within each target, but it appears that property setting is limited to the scope it’s done in, so if in setup, I set setup.has.been.invoked to true, that value only exists within setup.

What am I missing? Is there a section of the tutorials or online documentation I’ve skipped? Any pointers or hints?

  • 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-05-13T14:05:03+00:00Added an answer on May 13, 2026 at 2:05 pm

    You should remove the antcalls and add do.first and do.second as dependencies of do.several:

    <target name="do.several" depends="setup, do.first, do.second">
    </target>
    

    This will make sure, that setup is only called once:

    setup:
         [echo] In setup
    
    do.first:
         [echo] In do.first
    
    do.second:
         [echo] In do.second
    
    do.several:
    
    BUILD SUCCESSFUL
    Total time: 0 seconds
    

    Documentation says why a property set in setup does not work with antcall:

    The called target(s) are run in a new project; be aware that this means properties, references, etc. set by called targets will not persist back to the calling project.

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

Sidebar

Related Questions

Similar question here but this is slightly different... I have two tables that I
A similar question has been asked here: Class members that are objects - Pointers
There is similar question on this topic I participated in it, but it doesn't
A similar question discusses __construct , but I left it in my title for
Similar question as this one but for a Microsoft Environment. Email --> Exchange Server
A similar question has been asked: MSDN subscriptions on the cheap? , but I
There are similar question, but not regarding C# libraries I can use in my
My question is similar to Engram's here , but my question goes a bit
A similar question was asked and answered about a year ago, but was either
My question is similar to this one but I'm having some problems with the

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.