sbt plugin for generating configuration files
// To generate files from plain strings
addSbtPlugin("io.taig" % "sbt-blowout-core" % "[version]")
// To generate json files via circe
addSbtPlugin("io.taig" % "sbt-blowout-json-circe" % "[version]")
// To generate yaml files via circe-yaml
addSbtPlugin("io.taig" % "sbt-blowout-yaml-circe" % "[version]")
-
Register generators
enablePlugins(BlowoutPlugin) blowoutGenerators += BlowoutGenerator.strict( file("my-config.yml"), content = s"version: ${scalaVersion.value}" )
-
Install generators via sbt
sbt blowoutGenerate
A new file
./my-config.yml
in the root project directory of your project has now been created or overwritten if it already existed. -
Verify that your files generated by sbt-blowout are up-to-date, ideally as part of your CI pipeline
sbt blowoutCheck
This task will raise an error if a re-execution of
blowoutGenerate
would result in different file contents than the currently existing ones.
sbt-blowout generates configuration files of arbitrary formats and extensions with the sbt-blowout-core
module. Other modules (like sbt-blowout-yaml-circe
) provide additional helpers on top of that to ease generation of specific file formats. sbt-blowout can be useful to generate CI configurations (such as GitHub Action workflows), Dockerfiles, cloud deployment configurations or any other configuration file that can benefit from access to the sbt build configuration.
The YAML module uses circe-yaml in order to provide the convenient circe JSON builders before converting the AST to YAML.
enablePlugins(BlowoutYamlPlugin)
blowoutGenerators += BlowoutYamlGenerator.strict(
file("my-config.yml"),
content = Json.obj("version" := scalaVersion.value)
)
The JSON module uses circe in order to provide the convenient circe JSON builders.
enablePlugins(BlowoutJsonPlugin)
blowoutGenerators += BlowoutJsonGenerator.strict(
file("my-config.json"),
content = Json.obj("version" := scalaVersion.value)
)
Take a look at the GitHubActionsGenerator file which is used to generate the GitHub Action workflows that build and deploy this project. The generators are registered at the root project in the build.sbt and the generated files can be found in the .github/workflows/ folder.
This plugin is highly inspired by sbt-github-actions which provides a very similar workflow, but is limited to generating GitHub Actions workflow configuration files.