gpt4 book ai didi

Ant 任务

转载 作者:行者123 更新时间:2023-12-03 10:40:40 24 4
gpt4 key购买 nike

我现在看到 Ant 有两个 <include>任务和 <import>任务。
根据描述:

Include

Include another build file into the current project.



Import

Imports another build file into the current project.


那么,为什么要使用一个?
这是我的实际问题:
在我们当前的构建系统中,我们将一堆 JavaScript 连接起来,然后将它们最小化。 JavaScript 位于十几个不同的目录中,我们从每个目录中提取批次并将它们连接成五六个 super 最小化的 JavaScript。其中一些文件被复制到多个 super JavaScript 中。
为了使调试更容易,并且构建更灵活,我想将所有文件复制到 target/work/resources2 中。目录下的每个子目录代表不同的 super 最小化 JavaScript。出于调试目的,我们将包括非最小化的 super JavaScript 和原始版本。构建脚本并不复杂,但整个部分占用了很多行。我想把 <copy>把东西放到一个单独的 XML 文件中,所以整个事情看起来像这样:
<target name="process-resources"
description="Concatenate and minimize the JavaScripts (using Maven lifecycle names for our targets">
<!-- The following include the copying stuff -->
<here.be.dragons file="${basedir}/reservations.xml"/>
<here.be.dragons file="${basedir}/date.xml"/>
<here.be.dragons file="${basedir}/select.xml"/>

<for param="concat.dir">
<fileset dir="${work.dir]/resources2"/>
<sequential>
<here.I.am.concatenating.and.minimizing/>
</sequential>
</for>
</target>
我看到有四种可能性:
  • 使用 <ant/>调用进行复制的文件
  • 使用 <import/> (这可能不起作用,因为它可能无法包含在目标中)
  • 使用 <include/> (这可能不起作用,因为它可能无法包含在目标中)
  • 使用 Entity Include .

  • 我从不疯狂使用 <ant/><antcall>尽管这可能是执行此操作的好时机。 Entity Include 的想法会奏效,但这是大多数人不理解的东西,我担心它会引起必须支持我正在做的事情的人的困惑。 <import><include>在这种情况下可能无法使用,但我仍然很好奇有什么区别。

    最佳答案

    The documentation of import explains the difference :
    导入与包含有何不同?

    The short version: Use import if you intend to override a target, otherwise use include.

    When using import the imported targets are available by up to two names. Their "normal" name without any prefix and potentially with a prefixed name (the value of the as attribute or the imported project's name attribute, if any).

    When using include the included targets are only available in the prefixed form.

    When using import, the imported target's depends attribute remains unchanged, i.e. it uses "normal" names and allows you to override targets in the dependency list.

    When using include, the included targets cannot be overridden and their depends attributes are rewritten so that prefixed names are used. This allows writers of the included file to control which target is invoked as part of the dependencies.

    It is possible to include the same file more than once by using different prefixes, it is not possible to import the same file more than once.

    关于Ant <import> 与 <include> 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14203337/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com