views:

44

answers:

2

I'm about to create some complex Ant build files and I wanted find out what people think are best practices for naming ant tasks. It is going to build some Java, C++, compresses JavaScript, generate docs and lots more.

What tasks do you always add to an any script? Things like clean, build?

How to you name targets that make up a single target through dependencies (or don't you do this)? E.g. build.proj1 and build.proj2

Any other naming conventions do you follow?

+3  A: 

This link explains the typical targets you should have in your project.

Using standard targets helps with new team members (and any experienced Ant hands) quickly getting to grips with the build process.

From personal experience, I'd say clean, build, deploy/install, test (test for running your junits, findbugs etc)

For the dependent targets, we use a convention like below

<target name="build" depends="clean,compile">

<target name="compile" depends="compile.src, compile.test">
JoseK
A: 

Another common practice is a kind of 'private' target. Simply put a leading '-' before the target name, i.e. <target name="-yourprivatetarget" ... />. Thus it's impossible to call that target via command line, as : ant -f yourbuild.xml --yourprivatetarget won't work whereas ant -f yourbuild.xml -yourprivatetarget would.

Also a target without a description attribute won't be listed when using ant -projecthelp (or ant -p). So you have some kind of private / internal targets, but beware, some tools, i.e. Eclipse or similar will expose all targets in the Outline view of it's ant editor.

Finally => there's no real private/internal target in ant, but it's helpful sometimes

Regards, Gilbert

Rebse