Project

General

Profile

Actions

Bug #5554

open

Build system doesn't recompile using dependencies by default

Added by dhogan dhogan almost 13 years ago. Updated almost 13 years ago.

Status:
In Progress
Priority:
Normal
Category:
build system
Target version:
Start date:
11/28/2011
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
5554

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

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

Updated by Christopher Brooks almost 13 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.

--start--
bash-3.2$ touch ../r/src/org/ecoinformatics/seek/R/RConsole.java
touch ../r/src/org/ecoinformatics/seek/R/RConsole.java
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/RConsole.java
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/RExpression2.java 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/RExpression2.java uses unchecked or unsafe operations.
[compile] Note: Recompile with -Xlint:unchecked for details.
[compile] Compiling apple-extensions...
--end-

Note that with dependency analysis, two file were recompiled.

Actions #2

Updated by Derik Barseghian almost 13 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.

Actions #3

Updated by Christopher Brooks almost 13 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.

Actions #4

Updated by Derik Barseghian almost 13 years ago

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

Actions #5

Updated by Redmine Admin over 11 years ago

Original Bugzilla ID was 5554

Actions

Also available in: Atom PDF