System property is @Sources - how to provide a default value?
ZaziroZ opened this issue · comments
Looks like it is not supported:
@Sources("classpath:org/aeonbits/owner/variableexpansion/${env:-develop}.xml")
Here develop
would be a default value for env property.
Yes. It looks like it's not supported yet.
Although it feels like it may be not that hard to add the support, I may be wrong.
I did a little research and looks like changes need to be done for this pattern to look for an additional group.
Something like this:
private static final Pattern PATTERN = compile("\\$\\{([^:]+?)(:(.+?)?)?\\}");
as well as to this block to check if there is a group(3)
. And if there is one, then use its value instead of an empty string.
Sorry for not trying to come up with a pull request with the implementation, but hopefully the info above is useful to anyone who's going to work on this.
@ZaziroZ ${env:-develop}
looks like bash
syntax (with -
dash before the default value). Probably it would make more sense to use the same syntax as Spring does in its @Value
annotation (without the dash)