Skip to content

sbt plugin for generating configuration files

License

Notifications You must be signed in to change notification settings

taig/sbt-blowout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sbt blowout

CI & CD sbt-blowout-core Scala version support Scala Steward badge

sbt plugin for generating configuration files

Installation

// 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]")

Quickstart

  1. Register generators

    enablePlugins(BlowoutPlugin)
    
    blowoutGenerators += BlowoutGenerator.strict(
      file("my-config.yml"),
      content = s"version: ${scalaVersion.value}"
    )
  2. 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.

  3. 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.

Guide

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.

YAML

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)
)

JSON

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)
)

Example

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.

Acknowledgements

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.

About

sbt plugin for generating configuration files

Topics

Resources

License

Stars

Watchers

Forks

Languages