Habitat is a project mainly written in Clojure, it's free.
Environment-based configuration for Clojure projects.
Enviroment-based configuration for Clojure projects.
Requires Clojure 1.2.
[habitat "0.1.0-SNAPSHOT"]
Create a new clojure project.
Add habitat to your project management file (project.clj / pom.xml / whatever).
Create a habitat directory in your resources directory.
Create a default.clj in your resources/habitat directory: ;; Example default.clj {:my-config-item "hello world from default"}
Create a dev.clj in your resources/habitat directory: ;; dev.clj {:my-config-item :hello-world-from-dev}
Update your dependencies, start a repl and run: user=> (require 'habitat) user=> (habitat/habitat) ;defaults to :dev enviroment {:my-config-item :hello-world-from-dev}
To set the enviroment at runtime: ;; other-env.clj {:my-config-item :other-env}
% export JAVA_OPTS="-Dhabitat.env=other-env"; lein repl
user=> (require 'habitat)
user=> (habitat/habitat)
{:my-config-item :other-env}
You can also pass a keyword to habitat to manually set the environment: user=> (habitat/habitat :other-env)
Copyright (C) 2010 Zachary Kim
Distributed under the Eclipse Public License v1.0 http://www.eclipse.org/legal/epl-v10.html