Reads a file in the current working directory or a String as a plain text Java Properties file. The returned object is a normal Map with String keys. The map can also be pre loaded with default values before reading/parsing the data.
Fields:file
:
Optional path to a file in the workspace to read the properties from.
These are added to the resulting map after the defaults and so will overwrite any key/value pairs already present.
text
:
An Optional String containing properties formatted data.
These are added to the resulting map after file
and so will overwrite any key/value pairs already present.
defaults
:
An Optional Map containing default key/values.
These are added to the resulting map first.
Example:
def d = [test: 'Default', something: 'Default', other: 'Default']
def props = readProperties defaults: d, file: 'dir/my.properties', text: 'other=Override'
assert props['test'] == 'One'
assert props['something'] == 'Default'
assert props.something == 'Default'
assert props.other == 'Override'