Bug #5554

Build system doesn't recompile using dependencies by default

Added by dhogan dhogan almost 11 years ago. Updated over 10 years ago.

In Progress
build system
Target version:
Start date:
Due date:
% Done:


Estimated time:


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/
$ 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/
$ 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/.*\///' class RConsole implements RMainLoopCallbacks { public RConsole() { private RConsole console = null; console = new RConsole(); console = new RConsole();

javac_depend.diff (6.04 KB) javac_depend.diff dhogan dhogan, 11/28/2011 02:58 PM


#1 Updated by Christopher Brooks over 10 years ago

Folded in d. hogan's patch that optionally adds ant dependency analysis.
From the command line, use:
ant compile -Ddepend=true

or edit build-area/settings/build-properties.xml

Below is an example run, first with the default (depend=false)
and then with dependency analysis.

bash-3.2$ touch ../r/src/org/ecoinformatics/seek/R/
touch ../r/src/org/ecoinformatics/seek/R/
bash-3.2$ ant compile
[compile] Compiling r...
[compile] Compiling 1 source file to /Users/cxh/src/kepler/r/target/classes
[compile] Compiling apple-extensions...

bash-3.2$ touch ../r/src/org/ecoinformatics/seek/R/
bash-3.2$ ant compile Ddepend=true
[compile] Compiling r...
[compile] Deleted 2 out of date files in 0 seconds
[compile] Compiling 2 source files to /Users/cxh/src/kepler/r/target/classes
[compile] Note: /Users/cxh/src/kepler/r/src/org/ecoinformatics/seek/R/ uses or overrides a deprecated API.
[compile] Note: Recompile with -Xlint:deprecation for details.
[compile] Note: /Users/cxh/src/kepler/r/src/org/ecoinformatics/seek/R/ uses unchecked or unsafe operations.
[compile] Note: Recompile with -Xlint:unchecked for details.
[compile] Compiling apple-extensions...

Note that with dependency analysis, two file were recompiled.

#2 Updated by Derik Barseghian over 10 years ago

Hey Christopher, thanks for folding this in. Shouldn't we set things up so that by default depend=true, i.e. when simply using "ant compile"? It seems worth it.

#3 Updated by Christopher Brooks over 10 years ago

I'd be happy to have depend set to true, but did not want to make a potentially
significant change for fear of breaking things or slowing down the compile.

Derik, if you think it would be a good idea to set depend to true in
build-properties.xml, then please feel free to go ahead and make the change.

Mainly, I wanted feedback about whether the change was a good change before
changing the default.

#4 Updated by Derik Barseghian over 10 years ago

Ok, I'll try it out locally for awhile when I get back on kepler, and commit if no problems arise.

#5 Updated by Redmine Admin over 9 years ago

Original Bugzilla ID was 5554

Also available in: Atom PDF