Sometimes it may be useful to choose different JDK/JRE versions for Apache Ant to use to compile your code. As an alternative to modifying the JVM Configuration field on the Ant step, an administrator could use this approach.
By default the JVM Configuration field on the Ant step is set to ${env/JAVA_HOME} but can be set to any path containing a valid JRE. To make use of a select property you would start by referencing a property, let's say by using ${p:JAVA_HOME_LOOKUP}. Next, create a system property called JAVA_HOME_LOOKUP which contains the following groovy script:
${gvy: def ver = PropertyLookup.get("JAVA_HOME_PROP") if (!ver) { return ''; } return PropertyLookup.get("JAVA_HOME_$ver") ?: ver }
You can create additional system properties for each version of Java you want to make available to the workflow(s). The naming pattern should be JAVA_HOME_<Java Version> so for example: JAVA_HOME_IBM 1.6
Finally, on the workflow itself, create a user-overridable select property. Choose a meaningful default (a typical choice would be Oracle 1.5) and populate with the versions you provided path properties for in the above step. This way users can select which version of Java they would like to use as Ant's JAVA_HOME at build time or use a default in the case of CI builds. This method can be applied to other types of properties that might not be overridden in normal ways and you would like to have human readable lables rather than values to select from (such as paths in this example)