Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'include' support for properties files? #139

Closed
ghost opened this issue Feb 5, 2014 · 2 comments
Closed

'include' support for properties files? #139

ghost opened this issue Feb 5, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 5, 2014

I was wondering if the 'include' directiveshould be supported for properties files? I currently does not seem to work, but I can understand if this is intentional.

For example, if I have a file 'test.properties' with the following definition:

include file("test2.conf")
test.hello = "world"
test.open = "sesame"

And I specify it as my config like:

java -Dconfig.file=tests.properties -jar myjar.jar

Should I expect test2.conf to be included in my Config object?

Currently what I observe is that 'include' gets defined as a property key:

Config(SimpleConfigObject(...,"test":{"hello":"\"world\"","open":"\"sesame\""},...,"include":"file(\"test2.conf\")"}))

No worries if there are no plans to support this, I was hoping to use HOCON as a drop in replacement to give us some more flexibility/extensibility to our test framework configuration. We currently use property files and would be nice for us to have the capability to allow some to use HOCON configs, while allowing others to continue using things the way they were.

@havocp
Copy link
Collaborator

havocp commented Feb 5, 2014

It can't be supported because that is a valid properties file (as you can see, Java's properties parser interprets it as something). So if we allowed includes in properties files we'd be incompatible with them somehow, for example maybe you couldn't have a property named "include".

A more mundane issue is that we just use Java's properties parser and don't implement our own so there's no way to customize it really.

FWIW, in many cases renaming .properties files to .conf works or almost works, sometimes you have to add a few quotation marks for special characters.

Another option would be to pre-process .properties files yourself (potentially using a custom url protocol or ConfigIncluder as mentioned in another context here #122 (comment) ). You could do something as simple as regex out include statements and replace them with the included file.

@ghost
Copy link
Author

ghost commented Feb 5, 2014

Hi @havocp, thanks for the quick response. I agree with the rationale with regards to compatibility. I'll look into some of your suggestions as I think any of those will work for us!

@ghost ghost closed this as completed Feb 5, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant