I am using resource filtering to replace some ${values} in a property file.
e.g. the file contains
PROPERTY=${VALUE}
I want ${VALUE} to be replaced with environment variable $VALUE which works well if $VALUE is set when the build runs. Awesome.
However, these env vars are only set in our official build environment (by Jenkins) and not in developer builds so the ${values} are left in the property file after filtering which can break stuff. I’d rather not require env vars in developer environments as that always leads to fragile dev builds and whiny devs.
How can I use the environment variable value if its set and use another default property value if the env var isn’t set?
From my testing it works the other way around by default, in that properties set in the pom will override environment variables for the purpose of resource filtering.
Thanks
I’m using the profile for determining as
Please note
activeByDefaultis set to true with purpose to enable it by default.!mypropertymeans this property is missing or not existed.mypropertyis not existed, just use themypropertydefined at thepropertiesinstead.You may see further information at http://maven.apache.org/guides/introduction/introduction-to-profiles.html
I hope this may help to achieve your requirement.
Regards,
Charlee Ch.