SHocon is a simple, pure-Scala, alternative implementation of the HOCON specification.
SHocon ships with a native, Scala-idiomatic API, and a shim that mimics the Typesafe Config Java API, making it well-suited as a drop-in replacement wherever the Java implementation is not available, such as Scala.JS or Scala Native projects.
This implementation does not cover all of the corner cases of the original implementation. Issues and PRs are welcome!
Add these lines to your
addSbtPlugin("org.akka-js" % "sbt-shocon" % "0.4.0")
val root = project.in(file(".") .enablePlugins(ShoconPlugin) .settings( libraryDependencies += "org.akka-js" %% "shocon" % "0.4.0", // for Scala.js/Native or cross projects use %%% instead: // libraryDependencies += "org.akka-js" %%% "shocon" % "0.4.0" // add dependency on shocon file generation task // (not required, but otherwise you need to call shoconConcat manually before compilation!) compile in Compile := (compile in Compile).dependsOn(shoconConcat).value /* ... */ )
SHocon wouldn't have been possible without the enormous support of the R&D department of UniCredit lead by Riccardo Prodam. Started as a side-project it quickly grew into an important open source milestone. Check out other projects from the UniCredit team here
Loading of default configuration
In contrast to Typesafe config, which loads configuration files dynamically at run time, shocon compiles the default configuration returned by
ConfigFactory.load() statically into the the code. This includes all
reference.conf files found in the
resources directory of the project itself, as well as all
reference.conf files found in JARs on which the project depends. If there is an
application.conf file in the
resources directory of the project, this one will be included as well (after all
The resulting HOCON configuration file is assembled in
Note: For Scala.JS / Native / JVM projects only the
reference.config files located in either
jvm/src/main/resources are included; files in
shared/src/main/resources/ are ignored!
0.3.1 the parse phase is aggressively moved at compile time, please note that runtime parsing cost a lot in terms of performances.
You can control the contents of the included default configuration with the following sbt settings:
shoconLoadFromJars: set to false, if you don't want to include any
reference.conffiles found in JARs
shoconFilter: Function1[(String,InputStream), Boolean]: set this setting to a filter function that return
truefor all configuration files to be included; the first element in the tuple passed to the function is the absolute URL of the configuration file.