Skip to content
This repository has been archived by the owner on May 13, 2019. It is now read-only.


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


I originally created this library, but wanted the same capability for other JDK languages, so created That library now has more features and is what I'll continue to maintain and improve.


Utility library to override an object's properties with environment variable values.

Build Status

Available from the jcenter repository as: compile 'com.edgescope:env-config-loader-groovy:1.0.0'

Main Purpose

Let you define your application's configuration in a typed configuration, and allow its settings to be overridden by environment variables.

There are a dozen ways to configure your application, and configuration management is often rife with confusion, rot, and bugs.

The approach this tool takes is toward the technique, with the added benefit of using a typed configuration object, which lets you manage your configuration like code.

The main class/method is EnvConfigLoader.overrideFromEnvironment(T config, String environmentPrefix) where config is some object you've created, used for storing your config settings.

Example Usage

See the EnvConfigLoaderSpec and TestAppConfig for more thorough examples, but here's the idea:

Given an object that you used to store your configuration settings, with some local dev/testing defaults:

AppConfig {
    String hostName = ""
    String port = 80

Choose a prefix for your environment-specific overrides. e.g.: export FOO_HOST_NAME=""

Then wherever you initialize your app's startup configuration, do something like this:

AppConfig appConfig = EnvConfigLoader.overrideFromEnvironment(new AppConfig(), "FOO") 

The AppConfig instance will end up with a hostName of and port of 80.
i.e. It will have modified the hostName, and left the port with the original value.

Requirements, Behaviors, Limitations

  • Your configuration object must implement Cloneable. overrideFromEnvironment will not mutate your original object.
  • Your property names must strictly match camelCase naming structure.
  • It currently only supports a flat set of properties. i.e. It doesn't support nested objects in configuration.
  • It currently supports Strings, Integers, and BigDecimal types. Other types might work, but aren't tested. (I'm totally open to suggestion on more types; just haven't seen a need yet.)


groovy-all, logback-classic, and spock for testing.

Issues / Questions

Please open an issue and let me know if you think something's missing, confusing, or broken.


Utility library to override an object's properties with environment variable values.






No packages published