蚂蚁脚本中私有目标和公共目标之间的差异



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

公共目标

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

私人目标

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

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

很有趣。

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

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

public can be called by user

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

最新更新