Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Ant, can I use a property inside a target's "depends"?

Tags:

ant

I m trying to do this with Ant:

<property name="test" value="123"/>
<target name="helloworld" depends="${test}"/>

But I'm getting error "Target ${test} does not exist in this project."

So I m guessing I can do this?

like image 526
Yinan Avatar asked Sep 15 '09 16:09

Yinan


People also ask

How do I override property value in Ant?

Ant Properties are set once and then can never be overridden. That's why setting any property on the command line via a -Dproperty=value will always override anything you've set in the file; the property is set and then nothing can override it. This way: Anything set at the command line takes precedence over build.

How do I run a specific target in Ant?

Enclose the task name in quotes. Targets beginning with a hyphen such as "-restart" are valid, and can be used to name targets that should not be called directly from the command line. For Ants main class every option starting with hyphen is an option for Ant itself and not a target.

What is the difference between task and target?

Online documentation and books say that target is a stage of the entire build process, while task is the smallest unti of work.


1 Answers

You can use the AntCall Task to call a Task inside another Task.

<project>
    <target name="asdf">
        <property name="prop" value="qwer" />
        <antcall target="${prop}" />
    </target>

    <target name="qwer">
        <echo message="in qwer" />
    </target>
</project>

To make one depend on the other, you can set a parameter in the dependent task and check it in your calling task.

like image 193
drfloob Avatar answered Nov 12 '22 20:11

drfloob