Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant: How do I find out what target was invoked from the command line?

Tags:

ant

I'm using Ant 1.8.2. From within my build.xml file, how do I find out what targets were used on the command line when invoking Ant?

Thanks, - Dave

like image 317
Dave Avatar asked Sep 09 '11 15:09

Dave


People also ask

How do I call Ant target from command line?

To run the ant build file, open up command prompt and navigate to the folder, where the build. xml resides, and then type ant info. You could also type ant instead. Both will work,because info is the default target in the build file.

How do I list all Ant targets?

To show every target associated with a build. xml file, you need to run ant -p -v Also, ant -p build.

What is Antcall target?

When a target is invoked by antcall , all of its dependent targets will also be called within the context of any new parameters. For example. if the target doSomethingElse ; depended on the target init , then the antcall of doSomethingElse will call init during the call.

What is the default target in Ant?

As Ant runs, it displays the name of each target executed. As our example output shows, Ant executes prepare followed by compile . This is because compile is the default target, which has a dependency on the prepare target.


1 Answers

Use the ant.project.invoked-targets property:

 <echo message="Targets: ${ant.project.invoked-targets}"/>

It's new since ant 1.8, I think. Some more Ant built-in properties.

like image 163
Cata Avatar answered Oct 01 '22 22:10

Cata