如何使用 Ant 配置惰性或增量构建? [英] How to configure lazy or incremental build in general with Ant?

查看:29
本文介绍了如何使用 Ant 配置惰性或增量构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 编译器提供增量构建,因此 javac ant 任务也是如此.但大多数其他流程没有.

Java compiler provides incremental build, so javac ant task as well. But most other processes don't.

考虑到构建过程,它们将一些文件集(源)转换为另一组文件(目标).

Considering build processes, they transform some set of files (source) into another set of files (target).

我可以在这里区分两种情况:

I can distinct two cases here:

  1. Transformor 不能获取源文件的子集,只能获取整个集.在这里,我们只能进行延迟构建 - 如果没有修改源中的文件 - 我们跳过处理.
  2. 转换器可以获取源文件的子集并产生部分结果 - 增量构建.
  1. Transformator cannot take a subset of source files, only the whole set. Here we can only make lazy build - if no files from source was modified - we skip processing.
  2. Transformator can take a subset of sources files and produce a partial result - incremental build.

什么是 ant 内部、第三方扩展或其他工具来实现惰性和增量构建?您能否提供一些广泛使用的构建文件示例?

What are ant internal, third-party extensions or other tools to implement lazy and incremental build? Can you provide some widespread buildfile examples?

我对此特别感兴趣,特别是与 GWT 编译器一起使用.

I am interested this to work with GWT compiler in particular.

推荐答案

uptodate 任务是 Ant 的这个问题的通用解决方案.它足够灵活,可以在需要惰性或增量编译的大多数情况下工作.

The uptodate task is Ant's generic solution to this problem. It's flexible enough to work in most situations where lazy or incremental compilation is desirable.

我和你有同样的问题:我有一个 GWT 模块作为我的代码的一部分,我不想在不需要时支付(巨额!)重新编译它的成本.我的情况下的解决方案如下所示:

I had the same problem as you: I have a GWT module as part of my code, and I don't want to pay the (hefty!) cost of recompiling it when I don't need to. The solution in my case looked something like this:

<uptodate property="gwtCompile.mymodule.notRequired"
  targetfile="www/com.example.MyGwtModule/com.example.MyGwtModule.nocache.js">
    <srcfiles dir="src" includes="**"/>
</uptodate>

<target name="compile-mymodule-gwt" unless="gwtCompile.mymodule.notRequired">
    <compile-gwt-module module="com.example.MyGwtModule"/>
</target>

这篇关于如何使用 Ant 配置惰性或增量构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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