ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Gies <olivier.g...@bull.net>
Subject Re: private targets
Date Tue, 19 Feb 2008 01:52:52 GMT

> 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


Mime
View raw message