=== Hocon Configuration Format

The Hocon Configuration Format extends the Vert.x Configuration Retriever and provides the
support for the https://github.com/lightbend/config/blob/master/HOCON.md[HOCON] format.

It supports includes, json, properties, macros...

==== Using the Hocon Configuration Format

To use the Hocon Configuration Format, add the following dependency to the
_dependencies_ section of your build descriptor:

* Maven (in your `pom.xml`):

[source,xml,subs="+attributes"]
----
<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-config-hocon</artifactId>
  <version>5.0.7</version>
</dependency>
<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-config</artifactId>
  <version>5.0.7</version>
</dependency>
----

* Gradle (in your `build.gradle` file):

[source,groovy,subs="+attributes"]
----
compile 'io.vertx:vertx-config:5.0.7'
compile 'io.vertx:vertx-config-hocon:5.0.7'
----

==== Configuring the store to use HOCON

Once added to your classpath or dependencies, you need to configure the
`link:../../apidocs/io/vertx/config/ConfigRetriever.html[ConfigRetriever]` to use this format:

[source, java]
----
ConfigStoreOptions store = new ConfigStoreOptions()
  .setType("file")
  .setFormat("hocon")
  .setConfig(new JsonObject()
    .put("path", "my-config.conf")
  );

ConfigRetriever retriever = ConfigRetriever.create(vertx,
    new ConfigRetrieverOptions().addStore(store));
----

You just need to set `format` to `hocon`.

==== Override configuration using system environment variables

Hocon supports https://github.com/lightbend/config#optional-system-or-env-variable-overrides[system environment variable overrides] using keys with `CONFIG_FORCE_` prefix. You can use this feature by specifying `hocon.env.override` to `true` in the configuration:

[source, java]
----
ConfigStoreOptions store = new ConfigStoreOptions()
  .setType("file")
  .setFormat("hocon")
  .setConfig(new JsonObject()
    .put("hocon.env.override", true)
    .put("path", "my-config.conf")
  );

ConfigRetriever retriever = ConfigRetriever.create(vertx,
  new ConfigRetrieverOptions().addStore(store));
----