蚂蚁<进口>与<&包括GT;任务 [英] Ant <import> vs. <include> tasks

查看:184
本文介绍了蚂蚁<进口>与<&包括GT;任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在看到蚂蚁同时具有<包括> 任务和<进口方式> 任务

I now see Ant has both an <include> task and an <import> task.

据描述:

包含另一个构建文件到当前项目。

Include

Include another build file into the current project.

导入另一个构建文件到当前项目。

Import

Imports another build file into the current project.

那么,为什么要使用一个比其他?

So, why use one over the other?

下面是我实际的问题:

在我们当前构建系统,我们串联了一堆的JavaScript,然后尽量减少他们。该Java脚本位于十几个不同的目录,我们从每个目录服用批次,并将它们串联成五六个超级最小化的JavaScript。一些文件被复制到多个超级JavaScript脚本。

In our current build system, we are concatenating a bunch of JavaScripts and then minimizing them. The JavaScripts are located in a dozen different directories, and we are taking batches from each directory and concatenating them into five or six super minimized JavaScripts. Some of these files are copied into multiple super JavaScripts.

为了使调试容易,构建一个更灵活一点,我想所有的文件复制到目标/工作/ resources2 目录中各子下有重新presenting最小化的JavaScript不同的超级-directory。出于调试目的,我们将包括非最小化超JavaScript和原件。构建脚本并不复杂,但整个一节是占用了大量的线。我正想着把&LT的;复制&GT; 的东西到一个单独的XML文件,所以整个事情是这样的:

In order to make debugging easier, and the build a bit more flexible, I want to copy all of the files into the target/work/resources2 directory with each sub-directory under there representing a different super minimized JavaScript. For debugging purposes, we'll include the non-minimized super JavaScript and the originals. The build script isn't complex, but the whole section is taking up a lot of lines. I was thinking of putting the <copy> stuff into a separate XML file, so the whole thing looks like this:

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

我看到有四种可能性:

I see there are four possibilities:


  • 使用&LT;蚂蚁/&GT; 来调用做复印的文件

  • 使用&LT;进口/&GT; (这可能无法工作,因为它可能不能够被纳入目标内)

  • 使用&LT;包括/&GT; (这可能无法工作,因为它可能不能够被纳入目标内)

  • 使用href=\"http://ant.apache.org/faq.html#xml-entity-include\">实体包括的
  • Use <ant/> to call the files that do the copying
  • Use <import/> (which might not work because it might not be able to be included inside a target)
  • Use <include/> (which might not work because it might not be able to be included inside a target)
  • Use the Entity Include.

我对使用从未疯狂&LT;蚂蚁/&GT; &LT; antcall&GT; 虽然这可能是一个很好的时间来做到这一点。实体包含的意见可行,不过这东西大多数人不明白,恐怕这将导致谁也支持我在做什么的人混淆。在&LT;进口&GT; &LT;包括&GT; 可能无法在这种情况下使用,但我还在原地好奇的区别是什么。

I am never crazy about using <ant/> or <antcall> although this might be a good time to do this. The Entity Include idea will work, but that's something most people don't understand, and I am afraid it will cause confusion for people who have to support what I'm doing. The <import> and <include> may not be able to be used in this situation, but I'm still curious what the differences are.

推荐答案

进口的文档解释了区别

短的版本:采用进口,如果你打算覆盖目标,否则使用包括

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

在使用进口导入的目标是通过提供多达两个的名字。他们的正常的名字没有任何preFIX并可能有prefixed名(的值作为属性或导入项目的名称属性,如果有的话)。

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

在使用包括纳入目标是只在prefixed形式提供。

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.

在使用包括附带的目标不能被重写及其依赖的属性被改写,这样prefixed名才会被使用。这使得包含文件的作家来控制目标被调用的依赖关系的一部分。

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.

有可能通过使用不同prefixes到包括相同文件多于一次,则不能导入同一文件不止一次

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.

这篇关于蚂蚁&LT;进口&GT;与&LT;&包括GT;任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆