Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between private and public targets in ant scripts

I've recently discovered that there are several useful templates (in Eclipse) that can be added to the script. And among them "public target" and "private target". And here the templates:

public target

    <!-- ================================= 
          target: name              
         ================================= -->
    <target name="name" depends="depends" description="description">

    </target>

private target

    <!-- - - - - - - - - - - - - - - - - - 
          target: name                      
         - - - - - - - - - - - - - - - - - -->
    <target name="name">

    </target>

And i don't get it. What is the main difference? And what does the private target mean? Is it some specific feature in ant scripts or just code beautifying?

Just interesting.

like image 682
olshevski Avatar asked Apr 22 '11 09:04

olshevski


People also ask

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.

What is a target in ant?

A target is a container of tasks and datatypes that cooperate to reach a desired state during the build process. Targets can depend on other targets and Apache Ant ensures that these other targets have been executed before the current target.


2 Answers

A target which has a description is public because it appears when you execute

ant -projecthelp

The others are considered private because they don't appear by default.

like image 198
JB Nizet Avatar answered Oct 23 '22 07:10

JB Nizet


Here's an example

<project name="public_only" default="public">
    <target name="-private">
        <echo message="private" />
    </target>
    <target name="public" description="this task is public" depends="-private">
        <echo message="public" />
    </target>
</project>
like image 40
Laurent Picquet Avatar answered Oct 23 '22 09:10

Laurent Picquet