The ant apache manual clearly defines on the the use of the "if" property when there's a need to have certain ant targets run only for some criteria.
"A target also has the ability to perform its execution if (or unless) a property has been set. This allows, for example, better control on the building process depending on the state of the system (java version, OS, command-line property defines, etc.). To make a target sense this property, you should add the if (or unless) attribute with the name of the property that the target should react to. Note: In the most simple case Ant will only check whether the property has been set, the value doesn't matter, but using property expansions you can build more complex conditions. See the properties page for more details. For example:
Expanding on this need, here's how you pass the property on the command line so its picked up by the build script
$ant clean build -Dmodule-A-present=anyvalue
Ref: http://ant.apache.org/manual/targets.html