Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • regexp
    The Java regular expression to be used for selecting from the variable value or for replacing certain parts of the variable value. For more information see the Java Platform SE 6 API and other documents describing the according regular expression syntax more in detail.
  • select (one of both, select or replace must be given)
    Selection expression according to regexp, used to select certain groups from the expression defined in regexp and possibly combine them with several text around.
  • replace (one of both, select or replace must be given)
    Replacement expression according to regexp, used to replace the regular expression defined in regexp and possibly combine them with several text around.
  • defaultValue (optional)
    The default value to be used if the expression defined in regexp does not match the enclosing variable value at all.
  • casesensitive (optional, defaults to "true")
    Whether the regular expression matching should consider the case of alphabetic letters or not for matching.
  • global (optional, defaults to "false")
    Whether the replacement operation should be performed on the entire variable value, rather than just the first occurance. This has effect only on using together with replace.

Example:

What does this do?

Code Block
titleFiltering dynamic variable assignments using regular expressions
langxml
<dynamicvariables>

	<!--
   <variable name="previous.version" jarfile="${INSTALL_PATH}/${INSTALL_SUBPATH}/libs/config.jar"
              entry="release.properties" type="options"
              key="release.version"
   Read the property value of release.version in the resource release.properties from the root of the config.jar file.
	  Filter just the version string from the result, if there is one, otherwise return 'none'.
      -->
    checkonce="false" ignorefailure<variable name="trueprevious.version" conditionjarfile="upgradecheck">${INSTALL_PATH}/${INSTALL_SUBPATH}/libs/config.jar"
      <filters>         <regex regexpentry="([0-9]+(\.[0-9]+){2})" select="\1" defaultvalue="none"/>release.properties" type="options"
       </filters>
    </variable>      <variable namekey="RegExTestrelease.Select.Windowsversion"
checkonce="true"              checkonce="false" regkey="HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
              regvalue="Pathignorefailure="true" condition="upgradecheck">
      <filters>
        <regex regexp="([^;]*)(.*)"
 0-9]+(\.[0-9]+){2})" select="\1" defaultvalue="none"/>
      </filters>
    </variable>

select="\1"	<!--
      Read the value of the Windows system environment  defaultValue="(unmatched)"
         variable %PATH% directly from the Windows registry (can done smarter by ${SYSTEM[PATH]}).
     casesensitive="false"/> Filter just the first single path </filters>(if there are more separated </variable>by the ';' character). If there was a valid value, otherwise return '(unmatched)'.
      -->
    <variable name="RegExTest.ReplaceFirstSelect.Windows" checkonce="true"
              regkey="HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
              regvalue="Path">
      <filters>
        <regex regexp="([^;]*)(.*)"
               replaceselect="+++ \1 +++"
               defaultValue="(unmatched)"
               casesensitive="false"/>
      </filters>
    </variable>

	<!--
    global="false"/>  Read the value of  </filters>
    </variable>

    <variable name="RegExTest.ReplaceAll.Windows" checkonce="true"the Windows system environment variable %PATH% directly from the Windows registry (can done smarter by ${SYSTEM[PATH]}).
      Filter just the first single path (if there are more  regkey="HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
              regvalue="Path">
      <filters>
separated by the ';' character).
	  Prepend and append three plus signs to the resulting value, if there was a valid value, otherwise return '(unmatched)'.
       <regex regexp="([^;]*)"-->
    <variable name="RegExTest.ReplaceFirst.Windows" checkonce="true"
         replace="+++ \1 +++     regkey="HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
               defaultValueregvalue="(unmatched)Path">
      <filters>
        casesensitive<regex regexp="false([^;]*)"
               globalreplace="true"/>
+++ \1 +++"
               defaultValue="(unmatched)"
               casesensitive="false"
               global="false"/>
      </filters>
    </variable>

</dynamicvariables>

...

After straight evaluation, each dynamic variable value can be filtered to be canonicalized like a filename. This is done by the nested location element.

Attributes:

  • basedir
    The root directory relative path to be assumed when the origin value is not an absolute path. If not set, the current working directory is assumed as the base directory, instead.

Example:

What does this do?Operating system-specific path conventions are considered when assembling the result.

This means especially the file separator will be converted to that of the target operating system. On Windows, an absolute path is assumed to start with a drive letter followed by a colon, on Unix or MacOSX by a slash.

Furthermore all path parts containing /./ are replaced by the file separator and /dir/../ by the parent directory of dir.

Attributes:

  • basedir
    The root directory relative path to be assumed when the origin value is not an absolute path. If not set, the current working directory is assumed as the base directory, instead.

Example:

Assuming all defined conditions are met, the following definition converts all ${previous.wrapper.java.home.canonical}/bin/java not being an absolute path to a canonical path of the form

${INSTALL_PATH}/${previous.wrapper.java.home.canonical}/bin/java

on Unix or

${INSTALL_PATH}\${previous.wrapper.java.home.canonical}\bin\java

on Windows.

Code Block
languagehtml/xml
titleExample of the location filter
 <variable name="previous.wrapper.java.command.canonical" value="${previous.wrapper.java.home.canonical}/bin/java"
              condition="haveInstallPath+isCompatibleUpgrade+haveWrapperJavaCmd+isSetCanonicalJavaHome">
      <filters>
        <location basedir="${INSTALL_PATH}"/>
      </filters>
 </variable>