可以标准的Sun javac做增量编译吗? [英] Can standard Sun javac do incremental compiling?
问题描述
编辑:我没有使用Eclipse自动构建功能,而是设置
-Dbuild.compiler = org.eclipse.jdt.core.JDTCompilerAdapter $ b $对于我的蚂蚁构建,b
这是真的,Sun的编译器总是编译每个源文件,Eclipse的编译器只编译更改的文件那些受这种变化影响的那些?
我相信你是两个都是正确的。
您当然可以强制Eclipse重新编译所有内容。
但方程式的其他部分是Java构建工具(如Ant和Maven)只能编译已经更改的类,以及依赖类的树。
编辑
在Ant中,增量编译可以通过两种方式完成:
-
默认情况下,
< javac>
任务将时间戳.java
和相应的.class
文件,只告诉Java编译器恢复(.java)文件比其对应的目标(.class)文件更新,或者根本没有目标文件。 -
了解为什么Ant
< depend>
不是傻瓜的,请阅读文档。
Recently I started to use Eclipse's java compiler, because it is significantly faster than standard javac. I was told that it's faster because it performs incremental compiling. But I'm still a bit unsure about this since I can't find any authoritative documentation about both - eclispse's and sun's - compilers "incremental feature". Is it true that Sun's compiler always compiles every source file and Eclipse's compiler compile only changed files and those that are affected by such a change?
Edit: I'm not using Eclipse autobuild feature but instead I'm setting
-Dbuild.compiler=org.eclipse.jdt.core.JDTCompilerAdapter
for my ant builds.
Is it true that Sun's compiler always compiles every source file and Eclipse's compiler compile only changed files and those that are affected by such a change?
I believe that you are correct on both counts.
You can of course force Eclipse to recompile everything.
But the other part of the equation is that Java build tools like Ant and Maven are capable of only compiling classes that have changed, and their tree of dependent classes.
EDIT
In Ant, incremental compilation can be done in two ways:
By default the
<javac>
task compares the timestamps of.java
and corresponding.class
files, and only tells the Java compiler to recompile source (.java) files that are newer than their corresponding target (.class) files, or that don't have a target file at all.The
<depend>
task also takes into account dependencies between classes, which it determines by reading and analysing the dependency information embedded in the.class
files. Having determined which.class
files are out of date, the<depend>
task deletes them so a following<javac>
task will recompile them. However, this is not entirely fool-proof. For example, extensive changes to the source code can lead to the<depend>
task may be analysing stale dependencies. Also certain kinds of dependency (e.g. on static constants) are not apparent in the.class
file format.To understand why Ant
<depend>
is not fool-proof, read the "Limitations" section of the documentation.
这篇关于可以标准的Sun javac做增量编译吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!