Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Ant Performance when deleting directory

Hello fellow stackoverflowers,

Most Ant build files I've seen online involve a "clean" target that always removes a directory using deltree and recreates that directory, where all the binaries will be outputted to. Is this a performance problem? That is, a source file should only be compiled if it has been changed, but if the directory holding all the binaries is deleted after every build, then all files have to be recompiled on each build. Is this what happens, and if so, am I wrong in saying that this could really hurt performance.

As a follow up question, is doing this absolutely necessary or highly recommended when using Ant? My team happens to be using dropbox to sync to multiple machines, and we may not want this step to occur on every run.

Thanks for any input!

-alanhorizon

like image 496
Alan Avatar asked May 25 '26 07:05

Alan


2 Answers

Clean is generally superfluous if you are adding or changing existing classes. javac checks the timestamp ofclass files to keep them up to date.

It becomes essential if some classes have been deleted. If you don't clean up first, you end up with outdated class files sometimes causing dependency issues.

And no, performing a clean up is not a performance impact worth to mention compared to other tasks involved in the build/deployment process.

like image 106
kostja Avatar answered May 26 '26 20:05

kostja


You can often avoid the clean step and javac will only compile changes. For rapid development you can probably get away with it and just run clean when you run into a problem. For builds that you'll deploy it's safest to always do a clean first to deal with any intricate dependencies that might not work otherwise.

That said, why in the world are you sharing source with a team through Dropbox? You should use Subversion or Git (or plenty of others) for source control management. They're designed for this and you're going to want them as soon as you deal with anything potentially complex like branching and merging. Consider using GitHub if you want to avoid setting much up.

like image 43
WhiteFang34 Avatar answered May 26 '26 20:05

WhiteFang34