Skip to content
Daniel Szmulewicz edited this page Jun 8, 2015 · 39 revisions

Configuring Boot (and your project)

It is useful to distinguish two sets of orthogonal concerns in Boot: configuring Boot itself vs. configuring your Clojure project (that Boot is going to instrument).

tl;dr Boot itself is configured with environment variables, while your Clojure project is configured with build.boot.

Configuring Boot means controlling the JVM environment before your project is loaded. Configuring your Clojure project means declaring dependencies, specifying which tasks to run, etc. Environment variables and boot.properties are used in the first case, profile.boot and build.boot in the latter.

Configuring Boot itself

Configuring the Java environment that bootstraps Clojure is done via environment variables. Boot being a self-documented toolchain, you can query the environment variables that Boot understands by invoking boot -h on the command line.

  •      `BOOT_AS_ROOT`               Set to 'yes' to allow boot to run as root.
    
  •      `BOOT_CLOJURE_VERSION`       The version of Clojure boot will provide (1.6.0).
    
  •      `BOOT_HOME`                  Directory where boot stores global state (~/.boot).
    
  •      `BOOT_FILE`                  Build script name (build.boot).
    
  •      `BOOT_JVM_OPTIONS`           Specify JVM options (Unix/Linux/OSX only).
    
  •      `BOOT_LOCAL_REPO`            The local Maven repo path (~/.m2/repository).
    
  •      `BOOT_VERSION`               Specify the version of boot core to use.
    
  •      `BOOT_COLOR`                 Turn colorized output on or off
    

A special case that belongs in our Boot configuration chapter is when you want to pin your project to a specific Boot version. This is covered in depth here, but in a nutshell:

$ boot -V > boot.properties

Editing boot.properties by hand isn't recommended because it needs to have both BOOT_CLOJURE_VERSION and BOOT_VERSION and it needs to be a valid properties file, hence we capture the output of boot -V.

Precedence rules: Environment variables override boot.properties.

Configuring your project

profile.boot and build.boot configure you Clojure project, they impact the program that runs once clojure is bootstrapped. profile.boot is a global configuration file that lives in BOOT_HOME, which defaults to ~/.boot.

Precedence rules: profile.boot and build.boot are concatenated. Anything you do in profile.boot will be evaluated before the expressions in build.boot, so the expressions in build.boot can override, redef, etc anything done in profile.boot.

boot-shim.clj (Here be dragons)

This can be used to modify how boot works at the lowest levels, in every pod. For example, we could change the default repositories that boot uses to load itself during bootstrapping by creating a boot-shim.clj file either in the BOOT_HOME or the current working directory with the following contents:

    (try (require 'boot.aether)
         (eval '(reset! boot.aether/default-repositories
                        [["public"  {:url "http://repo.local/public/"}]
                         ["private" {:url "http://repo.local/private/"}]]))
         (catch Throwable _))

This file will be evaluated via clojure.core/load-file in each Clojure runtime that's created (all pods, including the main one in which the build.boot runs). Clojure core will be available but no boot-related code will have been loaded or run yet.

So you can use it to patch clojure core if you want or basically override anything in clojure or boot by doing alter-var-root, etc.

Clone this wiki locally