SBT plugin for loading *.env file variables into SBT global settings
Add the following code to your sbt project/plugins.sbt
:
resolvers += Resolver.bintrayRepo("nietsnie", "sbt-plugins")
addSbtPlugin("com.github.ikamman" %% "sbt-env" % "0.9.x")
After this step you will find all variables in the Global
scope:
envVariables in Global
Just create your .env
file near your build.sbt
:
vi .env
add your variables:
APPLICATION_VERSION=0.0.1-SNAPSHOT
# or
export SERVER_PORT=25
# or
URL_PATH="https://github.com/ikamman/sbt-env"
Here you can change the file name .env
envFileName in Global := "versions.env"
Due to fact that environment variables are stored in Setting[Map[String, String]]
you can change anything in your sbt configuration:
version := envVariables.value("APPLICATION_VERSION")
This plugin needs SBT 1.x+ version to work properly.
Big thanks to Matt Fellows and his sbt-dotenv amazing sbt plugin. It was the main inspiration to create this plugin.
This repo is itself an example ;)