Skip to content

Instantly share code, notes, and snippets.

@l-gu
Created June 18, 2020 17:22
Show Gist options
  • Save l-gu/72e062491b0e069d5e3ce0c456ed1bdd to your computer and use it in GitHub Desktop.
Save l-gu/72e062491b0e069d5e3ce0c456ed1bdd to your computer and use it in GitHub Desktop.
--- Getting an object value with a default value if not defined
#assertFalse($fn.isDefined("FOO2"), "F002 is not supposed to be defined!")
Getting "FOO2" : $fn.get("FOO2", "my default value")
--- Defining a variable if not already exists
Exemple 1 :
'NAMESPACE' has not been defined in the project variables
then it will be initialized with a default value
#set ( $NAMESPACE = $fn.get("NAMESPACE", "default-name" ) )
NAMESPACE = $NAMESPACE ## "default-name" (initialized)
Exemple 2 :
'AUTHOR' variable is already defined so it remains unchanged
#set ( $AUTHOR = "Bart" )
#set ( $AUTHOR = $fn.get("AUTHOR", "Homer" ) )
AUTHOR = $AUTHOR ## "Bart" (unchanged)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment