I've a whole load of Ant buildfiles, so I try to keep a certain level
of consistency and best practice across them. One thing still puzzles
me though: Just how much should the "clean" target remove?
What's it really for?
* To force a truly clean build, in spite of any possibly untrustworthy
dependencies?
* To clean up after a build ?
* To clean up after a build (but leave the "end product" still
available) ?
Of these three use-cases, only the first is really anything I ever
have call to _use_. Yet most implementations of "clean" are actually
somewhere between the 2nd and 3rd. I don't really need these -- who
ever cleans up _afterwards_ ?
Assume I have directories of base/src/ base/build/ base/build/
classes/ base/dist/ ,
Only base/src/ goes through source control, the others are all
generated during the build, and that all the deliverable jar or zip
files end up in base/dist/
Obviously clean needs to empty base/build/classes/, but what about the
others?
Should base/dist/'s contents survive ?
Any of base/build/ contents at all ?
Should clean also remove the directory structure itself ? Is this
important?
Thanks for any comments from others, re their practice here.
Rob Seegel - 07 Mar 2007 12:03 GMT
In my current setup, everything that gets generated by the build process
is put into a directory called target.
There is:
target/classes
target/generated-code
target/docs
target/dist
target/reports
There are other subdirectories as well, but you get the basic idea.
Anything generated by the build goes there. If the build process is
successful then a copy of the artifact *also* goes into a local
repository (which is not under target).
My clean target deletes the target directory, and everything inside it.
It keeps things extremely simple.
Our project is split up into several modules, each of which has their
own (extremely short) build file. A single module may have multiple
dependencies on other modules. So, in addition to clean, we have a
"clean-all" target which runs clean on the current project and any of
the modules it depends on. When run from our toplevel module, it
effectively cleans every module.
Rob
> I've a whole load of Ant buildfiles, so I try to keep a certain level
> of consistency and best practice across them. One thing still puzzles
[quoted text clipped - 24 lines]
> Should clean also remove the directory structure itself ? Is this
> important?