Location: JWare Software » AntXtras » Documents » How Tos » Enable Funcuts
Enable Funcuts
Q: How do I enable or disable function shortcuts?
If you declare your AntXtras tasks using the supplied all-in-one “org/jwaresoftware/antxtras/install” antlib, all of the built-in AntXtras function shortcuts are automatically installed and enabled for you to use immediately. No additional setup is required. You should use this mechanism if possible.
Enabling Function Shortcuts
If you do not use the all-in-one AntXtras antlib, the AntXtras binary distribution includes an antlib in the package “org/jwaresoftware/antxtras/funcuts” that has declarations for all of the built-in AntXtras function shortcuts. To use our shortcuts antlib as-is, copy one of the examples below. Note that in our antlib, we’ve used only the verbose but easy-to-understand shortcut names. You can create your own local antlib file that uses shorter names.
Examples
1) Load and enable the built-in AntXtras function shortcuts:
1: <typedef resource="org/jwaresoftware/antxtras/funcuts/antlib.xml"/>
2) If you have installed AntXtras in a custom XML namespace, you must use the same namespace URI when loading the function shortcuts antlib. In the example below, we declare the namespace URI as “jware.antxtras” on line 1; then we refer to the same URI when loading both the main AntXtras antlib (line 2) and the function shortcuts antlib (line 5).
1: <project name="sample" xmlns:t="jware.antxtras"…> 2: <taskdef uri="jware.antxtras" 3: resource="org/jwaresoftware/antxtras/antlib.xml" /> 4: … 5: <typedef uri="jware.antxtras" 6: resource="org/jwaresoftware/antxtras/funcuts/antlib.xml"/>
3) If you use the special Ant “antlib:” namespace URI to auto-load the main AntXtras antlib you will also need to specify the same namespace URI when loading the AntXtras function shortcuts antlib. In the example below, we declare the special antlib namespace for AntXtras on line 1; then we refer to the same URI when loading the function shortcuts antlib (line 2).
1: <project name="sample" xmlns:t="antlib:org.jwaresoftware.antxtras"…> 2: <typedef uri="antlib:org.jwaresoftware.antxtras" 3: resource="org/jwaresoftware/antxtras/funcuts/antlib.xml"/>
Disabling Function Shortcuts
If you want to disable AntXtras function shortcuts— which also disables recursive property expansion, you have to explicitly uninstall the feature using the special <managefuncuts> administration task. You can also disable (and re-enable) specific function shortcuts or uninstall built-in shortcuts and replace their definitions with your own implementation.
Examples
1) Disable and unload all function shortcuts permanently after loading the AntXtras from the all-in-one antlib. Using this command reverts to the standard Ant property expansion mechanism. Do this after loading AntXtras but as early in your Ant script execution as possible!
1: <managefuncuts action="uninstall"/>
2) Unload specific function shortcuts so they are no longer available. You would typically uninstall a built-in function shortcut so you could replace it with your own implementation. This example uninstalls the built-in $changelogdate: shortcut.
1: <managefuncuts action="uninstall"> 2: <parameter name="changelogdate"/> 3: </managefuncuts>
3) Define your own specific function shortcuts so they are available within Ant. You can either replace built-in shortcuts (first you should uninstall the built-in), or add to the built-in set. This example does both: it replaces the built-in $changelogdate: shortcut and adds one of its own, $isweekday:.
1: <managefuncuts action="enable"> 2: <parameter name="changelogdate" 3: value="org.mysoft.ant.funcuts.ChangeLogDate"/> 4: <parameter name="isweekday" 5: value="org.mysoft.ant.funcuts.IsWeekDay"/> 6: </managefuncuts>
4) Disable all function shortcuts so they can be re-enabled at a later time. Using this command does not uninstall the funcut feature permanently but it does let you switch back to the standard Ant property expansion mechanism temporarily.
1: <managefuncuts action="disable"/>
To re-enable function shortcuts and recursive property expansion again, you have to use the “enable” action as below.
1: <managefuncuts action="enable"/>