简体   繁体   English

ant脚本中私有和公共目标之间的区别

[英]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. 我最近发现有几个有用的模板(在Eclipse中)可以添加到脚本中。 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. 很有意思

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. 其他被认为是私有的,因为它们默认不显示。

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>
private targets, i.e targets which could not be called by the user called in script itself

while

public can be called by user

you often want to call internal / private targets to run just a small step in the build (particularly while developing new features) – you can't do this if the targets are private. 你经常想要调用内部/私有目标来在构建中运行一小步(特别是在开发新功能时) - 如果目标是私有的,你就不能这样做。 so you end up creating a second, public, target that calls the private target … and you end up doubling the size of your build files. 因此,您最终会创建一个调用私有目标的第二个公共目标...并最终使构建文件的大小加倍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM