15

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

公共目标

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

    </target>

私人目标

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

    </target>

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

只是有趣。

4

3 回答 3

19

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

ant -projecthelp

其他的被认为是私有的,因为它们默认不会出现。

于 2011-04-22T10:04:48.667 回答
6

这是一个例子

<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>
于 2012-12-07T15:19:20.950 回答
0
private targets, i.e targets which could not be called by the user called in script itself

尽管

public can be called by user

你经常想调用内部/私有目标来运行构建中的一小步(特别是在开发新功能时)——如果目标是私有的,你就不能这样做。因此,您最终创建了第二个公共目标,该目标调用了私有目标……您最终将构建文件的大小增加了一倍。

于 2011-04-22T10:02:46.987 回答