Skip to content
Micha Niskin edited this page Jan 29, 2015 · 82 revisions

The boot environment contains the current JVM classpath configuration state.

(get-env)
Returns the whole environment map.
(get-env key)
Returns the value associated with the given key, or nil if the key is not found.
(get-env key not-found)
Returns the value associated with the given key, or not-found if the key is not found.
(set-env! key val & kvs)
Sets the values for the given keys. Note that this may produce side effects, changes to the JVM's classpath, etc.

Note: Env settings must be printable and writable–the env must be able to be passed to Pods to configure them, so the env map must always be able to be round-tripped through pr-str and read-string.

Replace Env Value

Calling set-env! with regular key value pairs replaces the values with the newly specified ones:

(set-env! :source-paths #{"foo" "bar"})

It's important to understand that this does not always modify the JVM environment accordingly. For example, it's possible to use set-env! to remove dependencies from the boot env, but dependency JARs cannot be removed from classloaders in the JVM once they've been added.

Update Env Value

Since env values must be able to be printed and read by the Clojure reader only "simple" values can ever be in the env. The set-env! function exploits this so when the env value is a function it applies the function to the current env value and sets the new value to the result:

(set-env! :source-paths #(conj % "baz"))

The function must, of course, return a valid env value.

Env Keys

:resource-paths
A set of path strings. These paths will be on the classpath and the files contained will be emitted as final artifacts.
:source-paths
A set of path strings. These paths will be on the classpath but the files contained will not be emitted as final artifacts.
:asset-paths
A set of path strings. These paths will not be on the classpath but the files contained will be emitted as final artifacts.
:directories
A set of path strings — the directories on the class path. These are the actual temporary directories that boot copies files from source and resource paths into before building the project.

This key is used internally by boot. You probably don't want to alter this, but you may need to read from it, for example when creating pods that need special class path setup.

:target-path
A path string. This directory is where final artifacts will be written.
:dependencies
A vector of Maven coordinates (see pomegranate).
:repositories
A vector of Maven repositories (see pomegranate).
:wagons
A vector of Maven wagon dependencies (see :dependencies). These dependencies should contain wagons.clj files.
:local-repo

The path to the location of the local Maven repository (see pomegranate).

This key is used internally by boot. To set the local repository location you probably want to use the BOOT_LOCAL_REPO environment variable instead.

:offline?

When set to true dependencies will not be resolved or fetched from remote repositories (see pomegranate).

This has no effect on boot's initial bootstrapping phase.

:mirrors
A map of Maven mirrors (see pomegranate).
:proxy
A map of Maven proxy configuration (see pomegranate).
:transfer-listener
A Maven transfer listener configuration (see pomegranate).
Clone this wiki locally