tags:

views:

671

answers:

1

The documentation for ant's task states:

The performance of the depend task is dependent on a number of factors such as class relationship complexity and how many class files are out of date. The decision about whether it is cheaper to just recompile all classes or to use the depend task will depend on the size of your project and how interrelated your classes are.

I suspect that using the task before calling may speed up the build for the project I work on, and possibly prevent the need for clean builds in certain cases. However, the ant documentation is very cryptic for this task and I could use some clarification. I work with a large code base containing about 16k classes in src and 4k classes in testsrc. We build a core jar file containing about a quarter of the classes, followed by about 15 other jars that depend on the core.jar and not each other. I would just try it out, but our build.xml requires a lot of clean-up before I can make this change, and I want to understand the task better anyway.

+2  A: 

You need to be very careful with this. There are some things, like declaring constants like this:

public static final int FOO = 1;

that the depends on task (and javac itself) don't always pick up on (I am not 100% certain that the one above messes with Ant, but I know some things do).

I did use the depend task a long time ago and quickly removed it as I kept needed to do full builds to ensure that things were sane.

TofuBeer
This is a compile time optimization so it's a weakness of <javac> as well. Obviously there are cases where you still need a clean build. I'm asking if there are cases where <depend> deletes more files than <javac> recompiles.
Craig P. Motlin
from what I remember it was not enough given that I still had to do clean builds to ensure things were getting built properly. I decided that depend wasn't safe enough for my needs.
TofuBeer
From what I remember, yes, depend was more correct than javac (just not correct enough to use it over a clean build)
TofuBeer