You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by samuel alexander <sa...@gmail.com> on 2008/02/18 13:51:55 UTC

private targets

Hi All,

Is it possible to have a private target in an ant project? (Similar to a
private method in JAVA)
This private target should not be called from outside the project and it
should not be executable by user directly.
And I want to use this private target internally?
Is this possible? Please pass on your suggestions.

Thanks,
Sam.

Re: private targets

Posted by Olivier Gies <ol...@bull.net>.
> Hi All,
>
> Is it possible to have a private target in an ant project? (Similar to a
> private method in JAVA)
> This private target should not be called from outside the project and it
> should not be executable by user directly.
> And I want to use this private target internally?
> Is this possible? Please pass on your suggestions.
>   

You can prefix your target name with an hyphen, '-', which make it 
impossible to be called from Ant command line:

For example:

<project>
    <target name="main" depends="-internal, external">
       ...
    </target>

    <target name="-internal">
       ...
    </target>

    <target name="external">
       ...
    </target>
</project>

Then from command line, different results:
C:\>ant main
Buildfile: build.xml

-internal:

external:

main:

BUILD SUCCESSFUL
Total time: 0 seconds

C:\>ant external
Buildfile: build.xml

external:

BUILD SUCCESSFUL
Total time: 0 seconds

C:\>ant -internal
Unknown argument: -internal
ant [options] [target [target2 [target3] ...]]
Options:
  [ cut for ML conciseness ... ]

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


AW: private targets

Posted by Ja...@rzf.fin-nrw.de.
It is not possible to have a real private target. You can "hide" targets:
a) a target without a "description" is not printed when using "-projecthelp", if there is
   one target with a description
b) a target with a leading "-" can not be called from the command line because the command line
   interface checks for leading "-" for options.

But because there is no concept of "private targets" in Ant other user interfaces (like Eclipse)
can expose all targets. (Speaking for Eclipse it can also hide "private" targets, but that's a
configuration of the workspace.)


Jan


> -----Ursprüngliche Nachricht-----
> Von: Tim Meals [mailto:tim@codeknox.com] 
> Gesendet: Dienstag, 19. Februar 2008 05:04
> An: Ant Users List
> Betreff: Re: private targets
> 
> Sam --
> 
> If you don't enter in a description attribute to the target, then it
> won't enumerate in the -projecthelp display.  I find this helpful in
> having internal targets vs. external targets that will be 
> called by users.
> 
> Tim
> 
> samuel alexander wrote:
> > Hi All,
> >
> > Is it possible to have a private target in an ant project? 
> (Similar to a
> > private method in JAVA)
> > This private target should not be called from outside the 
> project and it
> > should not be executable by user directly.
> > And I want to use this private target internally?
> > Is this possible? Please pass on your suggestions.
> >
> > Thanks,
> > Sam.
> >
> >   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: private targets

Posted by Tim Meals <ti...@codeknox.com>.
Sam --

If you don't enter in a description attribute to the target, then it
won't enumerate in the -projecthelp display.  I find this helpful in
having internal targets vs. external targets that will be called by users.

Tim

samuel alexander wrote:
> Hi All,
>
> Is it possible to have a private target in an ant project? (Similar to a
> private method in JAVA)
> This private target should not be called from outside the project and it
> should not be executable by user directly.
> And I want to use this private target internally?
> Is this possible? Please pass on your suggestions.
>
> Thanks,
> Sam.
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org