Thursday, August 31, 2006

JUNIT Elements Discovered

"<"target name="target-name" depends"mothertarget" if="someproperty"">"

When i run ant target-name ... following things will happen
1. The target's dependent taget is run first
2. Then there will be a check to see if "someproperty" is set, it dose not matter whether it is set to true or false or some junk value. And it can be set as a "proeprty element in the same build.xml or it can be set in build.properties file too.
3. if "someproperty" is set to some value, then the target "target-name" is run other wise only the target on which it depends would have ru, but the current target will be skipped

"<"antcall">"

This Element can be used to call any target with in the same build.xml file.
My Tip : This is very useful in cases where you want conditional invoking of a target.
here is an example: You want to build and test only if a property is set, other wise you want to just test. You can achieve this by doing the following.

BEFORE conditional build and test is implemented

"<"target name="testall" depends="build-all">"
....
"<"/target">"

AFTER conditional build and test is implemented

"<"target name="condition_check" if="build_and_test_is_set">"
"<"antcall target="build-all">" "<"/antcall">"
"<"/target">"

"<"target name="testall" depends="condition_check">"
....
"<"/target">"

No comments: