Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are good Ant target naming conventions?

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?

like image 857
RichH Avatar asked Jun 30 '10 00:06

RichH


2 Answers

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
<target name="yourprivatetarget" ... /> and 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

like image 55
Rebse Avatar answered Oct 26 '22 23:10

Rebse


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">
like image 28
JoseK Avatar answered Oct 26 '22 23:10

JoseK