1

I tried the following in ant:

<?xml version="1.0"?>
<project name="test" default="real" basedir=".">
  <target name="task">
    <mkdir dir="${value}" />
  </target>
  <target name="real" depends="task">
    <property name="value" value="real" />
  </target>
  <target name="fake" depends="task">
    <property name="value" value="fake" />
  </target>
</project>

But it didn't work as I expected: the property is defined after the task is executed.

How can I define a variable in a task, and then call another task?

1 Answer 1

1

Because both the real and fake tasks depend on task, it means that task is executed first. That's how ant resolves task dependencies.

You could look at the antcall task to call another target after setting a variable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.