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

发布于 2024-11-03 03:47:07 字数 676 浏览 1 评论 0原文

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

公共目标

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

    </target>

私有目标

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

    </target>

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

很有趣。

I've recently discovered that there are several useful templates (in Eclipse) that can be added to the script. 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

热鲨 2024-11-10 03:47:07

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

ant -projecthelp

。其他目标被视为私有,因为默认情况下它们不会出现。

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.

南薇 2024-11-10 03:47:07

这是一个例子

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

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>
反差帅 2024-11-10 03:47:07
private targets, i.e targets which could not be called by the user called in script itself

虽然

public can be called by user

您经常希望调用内部/私有目标来运行构建中的一小步(特别是在开发新功能时),但如果目标是私有的,则无法执行此操作。所以你最终创建了第二个公共目标来调用私有目标......并且最终你的构建文件的大小增加了一倍。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文