如何使用 Ant 配置惰性或增量构建?
Java 编译器提供增量构建,因此 javac ant 任务也是如此。但大多数其他进程则不然。
考虑到构建过程,它们将一组文件(源)转换为另一组文件(目标)。
我可以在这里区分两种情况:
- Transformator 不能获取源文件的子集,只能获取整个集合。这里我们只能进行延迟构建 - 如果源文件没有被修改 - 我们跳过处理。
- Transformator可以获取源文件的子集并生成部分结果 - 增量构建。
什么是 ant 内部、第三方扩展或其他工具来实现惰性和增量构建? 您能提供一些广泛使用的构建文件示例吗?
我特别感兴趣的是与 GWT 编译器一起使用。
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:
- 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.
- Transformator can take a subset of sources files and produce a partial result - incremental build.
What are ant internal, third-party extensions or other tools to implement lazy and incremental build?
Can you provide some widespread buildfile examples?
I am interested this to work with GWT compiler in particular.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
uptodate 任务是 Ant 针对此问题的通用解决方案。它足够灵活,可以在大多数需要惰性或增量编译的情况下工作。
我遇到了和你一样的问题:我有一个 GWT 模块作为我的代码的一部分,并且我不想在不需要时支付(高昂的!)重新编译它的成本。我的案例的解决方案看起来像这样:
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.
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:
与 GWT 相关,不可能进行增量构建,因为 GWT 编译器会立即查看所有源代码并优化和内联代码。这意味着未更改的代码可能会以不同的方式进行评估,例如,如果您开始使用未更改的类中的方法,则该方法在之前的编译步骤中被省略,但现在需要进行编译。
Related to GWT, it's not possible to do incremental builds because the GWT compiler looks at all the source code at once and optimizes and inlines code. This means code that wasn't changed could be evaluated differently, for example if you start using a method from a class that wasn't changed, the method was in the previous compilation step left out, but now needs to be compiled in.