13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

224Chapter 9Ant: An Introducti<strong>on</strong>nameThe name of the target. This is the name entered as an argument to ant.This is also the name that may be used in the default attribute of theproject tag.unlessThis is the reverse of the if attribute. The target is built unless theproperty is set.9.4.2.3 PropertiesThere is more than <strong>on</strong>e way to set what we might call variables in ant. The<strong>on</strong>ly <strong>on</strong>e we will c<strong>on</strong>cern ourselves with here is properties. Properties are like asimple hash, or associative array. They associate value, which is stored as aString, with a name, which is also a String. They behave very much like theProperties class introduced earlier in this book. 7 You can use buildfile propertiesto associate a single name with a single value that you use in multipleplaces throughout the buildfile to make c<strong>on</strong>figurati<strong>on</strong> changes easier and lesserror-pr<strong>on</strong>e. Some tasks also expect certain properties to be set, as we shallso<strong>on</strong> see.You set a property with the property tag (Example 9.2).Example 9.2 A useless build.xml example to dem<strong>on</strong>strate propertiesThis example's usefulness:${example.utility}. OK?Running ant with Example 9.2 gives this output:7. In fact, an examinati<strong>on</strong> of the ant source code reveals that ant properties are stored in aHashTable.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!