Bug #5554
openBuild system doesn't recompile using dependencies by default
0%
Description
The build system is using the Javac task's default dependency mechanism which checks mtimes of source code vs. class files. This misses a lot of dependencies. For instance, if you update an interface, it won't recompile all of the classes that implement that interface. It also doesn't recompile any references to the class from other files.
Ant has an optional task, Depend, which handles most of these dependency problems. It parses the class files to build a set of dependencies. It will delete stale class files so that javac recompiles them.
This is a partial solution for the part that I need, CompileModules. This could be used anywhere Javac is called. I set it up by default to disable the extra dependency checking. Edit settings/build-properties.xml to turn it on.
Without this patch, I have to remove <module>/target/classes periodically since it doesn't catch when I need to recompile properly.
Example: Touch RConsole which is referenced by RExpression2.
Without the patch:
$ touch ../r/src/org/ecoinformatics/seek/R/RConsole.java
$ ant compile
...
[compile] Compiling r...
[compile] Compiling 1 source file to ...
With the patch (and set depend = true in settings/build-properties.xml):
$ touch ../r/src/org/ecoinformatics/seek/R/RConsole.java
$ ant compile
...
[compile] Deleted 2 out of date files in 0 seconds
[compile] Compiling 2 source files to ...
If you ran with the patch and depend=true, it should have created ./depcache/<module>/dependencies.txt. Depend uses that information to determine which class files to delete.
I tested this with ant 1.7.0.
It should recompile both files and not just RConsole:
$ grep RConsole ../r/src/org/ecoinformatics/seek/R/* | sed -e 's/.*\///'
RConsole.java:public class RConsole implements RMainLoopCallbacks {
RConsole.java: public RConsole() {
RExpression2.java: private RConsole console = null;
RExpression2.java: console = new RConsole();
RExpression2.java: console = new RConsole();
Files