Simple Dotenv implementation for Scala SBT Builds. Configures environment for local development.
Scala Java Shell
Switch branches/tags
Nothing to show
Clone or download
mefellows Merge pull request #21 from eddsteel/expand-variables
Add support for variable expansion
Latest commit 17968bd Jul 14, 2018
Permalink
Failed to load latest commit information.
project
scripts
src
.gitignore
.travis.yml
LICENSE
README.md
build.sbt
version.sbt

README.md

sbt-dotenv

Build Status Current Version License

sbt plugin to load environment variables from .env into the JVM System Environment for local development.

Storing configuration in the environment is one of the tenets of a twelve-factor app. Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables.

But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. sbt-dotenv loads variables from a .env file into ENV when the environment is bootstrapped.

sbt-dotenv is intended to be used in development.

Installation

Add the following to your sbt project/plugins.sbt file:

addSbtPlugin("au.com.onegeek" %% "sbt-dotenv" % "1.2.88")

That's it - as soon as you start using sbt the environment is prepared.

Usage

Create a .env file in the root of your project with some environment specific settings. For example, you might want to set a Mongo DB port to 17017 if it's installed by Homebrew.

vi .env

MONGO_PORT=17017
WHO=you
I_BLOW_MY_NOSE=At $WHO

Variable expansion of the form $FOO and ${FOO} is supported based on the values in .env or the system environment.

Should I commit my .env file?

It is recommended that you store development-only settings in your .env file, and commit it to your repository. Make sure that all your credentials for your development environment are different from your other deployments. This makes it easy for other developers to get started on your project, without compromising your credentials for other environments.

sbt version

Please note that this plugin takes advantage of sbt Auto Plugins and therefore only works in sbt v0.13.5+

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature') and, optionally, squash history (git rebase -i <previous commit hash>)
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request