Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse ant脚本中私有目标和公共目标之间的差异_Eclipse_Templates_Ant_Build.xml - Fatal编程技术网

Eclipse ant脚本中私有目标和公共目标之间的差异

Eclipse ant脚本中私有目标和公共目标之间的差异,eclipse,templates,ant,build.xml,Eclipse,Templates,Ant,Build.xml,我最近发现有几个有用的模板(在Eclipse中)可以添加到脚本中。其中有“公共目标”和“私人目标”。以下是模板: 公众目标 私人目标 我不明白。主要区别是什么?那么私有目标是什么意思?这是ant脚本中的某些特定功能还是只是代码美化 很有趣 private targets, i.e targets which could not be called by the user called in script itself 当 public can be called by user 您通

我最近发现有几个有用的模板(在Eclipse中)可以添加到脚本中。其中有“公共目标”和“私人目标”。以下是模板:

公众目标


私人目标


我不明白。主要区别是什么?那么私有目标是什么意思?这是ant脚本中的某些特定功能还是只是代码美化

很有趣

private targets, i.e targets which could not be called by the user called in script itself

public can be called by user

您通常希望调用内部/私有目标来运行构建过程中的一小步(尤其是在开发新功能时)——如果目标是私有的,则无法这样做。因此,您最终创建了第二个、公共的、调用私有目标的目标…并且您最终将生成文件的大小增加了一倍。

具有描述的目标是公共的,因为它在执行时出现

ant -projecthelp
其他的被认为是私有的,因为默认情况下它们不会出现。

下面是一个例子

<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>


这只取决于注释样式?how interest=)@Raigomaru-使目标公开的是
description
属性的存在,而不是注释样式。此外,您可以强制执行只能从脚本本身内部调用私有目标(即在
依赖的
其他任务列表中)如果您给他们一个以“-”字符开头的名称,则不会在命令行上指定。实际上,没有任何东西可以阻止用户调用私有目标。从ant的角度来看,ant中的私有目标和公共目标是相同的。它不同于类中的私有和公共方法。公认的答案是目标是私有的,因为缺少
description
属性,我了解到破折号是私有目标名称的第一个字符。它只是一个惯例还是有句法意义?
ant -projecthelp
<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>