Table of Contents

Function Shortcuts

   This section summarizes and references all of the JWare learning materials available for AntXtras’s Function Shortcuts (funcuts) feature. For developers, this information is complemented by the AntXtras Javadocs; if you cannot find the information in the pages listed below, try the associated shortcut’s Javadoc pages which is listed in the “Related Topics” section of the function shortcut’s description.

Overview

AntXtras extends the standard Ant property dereference semantics and property naming conventions with a mechanism it calls Function Shortcuts (or funcuts for short) to expose your executing environment’s fixture, utility tasks, and select Ant functions. By using the existing property dereference mechanism AntXtras is able to help you avoid verbose XML script as well as “properties debris” or “properties junk” when trying to do simple, common bits of work. Read “Function Shortcuts-- why this is useful” for a detailed explanation of function shortcuts utility.

Format

The general form or URI of a function shortcut is ${$scheme:[fragment]} where the $scheme: portion selects one of a script-controlled set of function shortcuts and the optional fragment portion defines a query specific to a request and scheme. Note that there are two dollar signs in a function shortcut’s property dereference; the first is the trigger for Ant to parse the contents of the {…} and the second identifies the property name as an AntXtras funcut. The AntXtras function shortcut mechanism is open-ended; just as you can define additions to Ant’s standard conditions, tasks, and other types, you can rename most of our funcuts or add your own to AntXtras.

Chains

You can chain function shortcuts by piping the results of the first shortcut into a second and those results into a third and so on; for example “${$property:nextfile|$basename:|$uppercase:}” converts the basename of the path defined in the ‘nextfile’ property to all uppercase. The pipe instruction is the “|” (vertical bar). Only the first shortcut can have a query portion in its fragment; subsequent shortcuts are passed a fragment that is composed of the results of the preceding shortcut and any custom query string.

Recursion

Function shortcuts work as you would expect with the AntXtras recursive property expansion mechanism. This means you can easily pass fixture elements like properties and variables in as parameter values to funcuts; for example: “${$basename:${nextfile}|$uppercase:}”.

Standard Function Shortcuts

AntXtras provides the following function shortcuts although not all of them are installed automatically when you load the core AntXtras antlib. To get every available funcut you must also install the advanced AntXtras antlib.

Funcut Scheme(s) General Description
$p: or $property: Fixed shortcut.1) Extracts the named property’s current setting and supports a special dereference ‘→’ to get at items inside a <properties> or <propertyset>. You can also specify a default value if the named property is not defined.
$v: or $var: Fixed shortcut.2) Extracts the named variable’s current setting. You can also specify a default value if the named variable is not defined.
$r: or $ref: Fixed shortcut.3) Extracts the named reference’s current setting as a simple string. This funcut depends on the referenced object to implement a useful “to string” method.
$string: or $message: Extracts a message from the current Ant fixture’s installed message resource bundles. You can also specify up to ten (10) message template parameters.
$x: or $fixture: Extracts a named piece of Ant runtime information within the context of the funcut’s enclosing target. For example, you can use the $x: funcut to extract the enclosing target’s name or line number.
$system:, $sysenv:, $default: Extracts the named Java System property or environment variable. Lets you gain access to the platform environment variables without having to load all of them. You can also specify a default value if the named item is not defined.
$osfamily:, $oslibext: etc. Extracts various platform-specific definitions of common attributes. Useful when you need to create cross-platform or cross-version Ant scripts.
$password: Extracts a password from a password file on the filesystem. Lets you create scripts that use passwords without having to load the passwords into Ant properties that can be inadvertently leaked.
$anytrue:, $isnumber:, $noneset:, $not:, $isfile:, etc. Executes the named AntXtras short hand condition and reflects its results as a simple boolean string. The complete list of short hand conditions is defined in the Function Shortcuts Guide. Like inlined versions of AntXtras’s new conditions that you can use with flow control tasks.
$test or $criteria: Executes the named AntXtras <tallyset> or <criteria> and reflects its results as a simple boolean string. Lets you seamlessly link taskset execution with complex execution criteria.
$ospath:, $uppercase:, $stripws:, $trim: etc. Converts the fragment part of the shortcut according to the named transformation. Currently limited to a subset of the <copyproperty>’s transform parameter.
$now:, $datetime:, $iso:, $duration:, etc. Converts the current system time or a passed in timestamp according to the named datetime formatter. The complete list of datetime formats is defined in the Function Shortcuts Guide.
$millis: Lets you convert a human-readable duration description string to its milliseconds equivalent. For example, converts the string “5min+30sec” into “330000”.
$list:, $map: Extracts information from a structured list or map data object like a <strings>, <properties>, or other general Ant resource collection object. Because several AntXtras tasks let you generate item collections dynamically, you need a way to access such an item’s contents.

Additional Links

Notes and Caveats

1) , 2) , 3) You cannot uninstall fixed shortcuts.