Talk given at ClojureD in Berlin in January 2015.
Hi
View Slide
WHAT'S BOOT?
WHY ANOTHERBUILD TOOL?
<br/>(page "index.html"<br/>(:refer-clojure :exclude [nth])<br/>;; A lot more ClojureScript<br/>
NO ABSTRACTIONS FORBUILD PROCESSES
TIME PASSES...
2.0
HOW
TASKSABSTRACTIONS FORBUILD PROCESSES
;; build.boot(set-env!:source-paths #{"src"}:dependencies'[[pandeiro/boot-http "0.4.2"]...])(require'[pandeiro.boot-http :refer [serve]]...)(deftask run [](comp (serve) ; serve files(speak) ; audible notifications(watch) ; trigger new builds(cljs-repl) ; cljs REPL - hah!(reload) ; Figwheel style reloading(build)))
;; build.boot(set-env!:source-paths #{"src"}:dependencies'[[pandeiro/boot-http "0.4.2"]...])(require'[pandeiro.boot-http :refer [serve]]...)(deftask build [](comp (cljx)(cljs)(garden)))(deftask run [](comp (serve) ; serve files(speak) ; audible notifications(watch) ; trigger new builds(cljs-repl) ; cljs REPL - hah!(reload) ; Figwheel style reloading(build)))
COMPOSE ALL THE THINGS
BUT...SIDE EFFECTSEVERYWHERE?
FILESETFILES AS VALUES
DEPENDENCYISOLATION
PODSISOLATED CLOJURERUNTIMES
TWO MORE QUICK THINGS
TASK OPTIONS(boot (cljs :optimizations :advanced)) ; REPL
TASK OPTIONS(boot (cljs :optimizations :advanced)) ; REPLCLI <> REPL SYMMETRYboot serve watch cljs -O advanced # SHELL(boot (serve) (watch) (cljs :optimizations :advanced)) ; REPL
Demo
(ns boot-garden.core{:boot/export-tasks true}(:require [clojure.java.io :as io][boot.core :as boot :refer [deftask]][boot.pod :as pod][boot.file :as file][boot.util :as util]))(def initial(atom true))(defn add-dep [env dep](update-in env [:dependencies] (fnil conj []) dep))(defn ns-tracker-pod [](pod/make-pod (assoc-in (boot/get-env) [:dependencies] '[[ns-tracker "0.2.2"]])))(defn garden-pool [](pod/pod-pool (add-dep (boot/get-env) '[garden "1.2.5"]):init (fn [pod] (pod/require-in pod 'garden.core))))(deftask garden"compile garden"[o output-to PATH str "The output css file path relative to docroot."s styles-var SYM sym "The var containing garden rules"p pretty-print bool "Pretty print compiled CSS"v vendors [str] "Vendors to apply prefixed for"a auto-prefix [str] "Properties to auto-prefix with vendor-prefixes"](let [output-path (or output-to "main.css")css-var styles-varns-sym (symbol (namespace css-var))tmp (boot/temp-dir!)out (io/file tmp output-path)src-paths (vec (boot/get-env :source-paths))garden-pods (garden-pool)ns-pod (ns-tracker-pod)](pod/with-eval-in ns-pod(require 'ns-tracker.core)(def cns (ns-tracker.core/ns-tracker ~src-paths)))(boot/with-pre-wrap fileset(when (or @initial (some #{ns-sym} (pod/with-eval-in ns-pod (cns))))(let [c-pod (garden-pods :refresh)](if @initial (reset! initial false))(util/info "Compiling %s...\n" (.getName out))(io/make-parents out)(pod/with-eval-in c-pod(require '~ns-sym)(garden.core/css {:output-to ~(.getPath out):pretty-print ~pretty-print:vendors ~vendors:auto-prefix ~(set auto-prefix)} ~css-var))))(-> fileset (boot/add-resource tmp) boot/commit!))))
(ns boot-garden.core{:boot/export-tasks true}(:require [clojure.java.io :as io][boot.core :as boot :refer [deftask]][boot.pod :as pod][boot.file :as file][boot.util :as util]))
;; (ns boot-garden.core;; {:boot/export-tasks true};; (:require [clojure.java.io :as io];; [boot.core :as boot :refer [deftask]];; [boot.pod :as pod];; [boot.file :as file];; [boot.util :as util]))(def initial(atom true))
;; ...;; (def initial;; (atom true))(defn add-dep [env dep](update-in env [:dependencies] (fnil conj []) dep))(defn ns-tracker-pod [](pod/make-pod (assoc-in (boot/get-env) [:dependencies] '[[ns-tracker "0.2.2"]])))(defn garden-pool [](pod/pod-pool (add-dep (boot/get-env) '[garden "1.2.5"]):init (fn [pod] (pod/require-in pod 'garden.core))))
;; ...;; (defn garden-pool [];; (pod/pod-pool (add-dep (boot/get-env) '[garden "1.2.5"]);; :init (fn [pod] (pod/require-in pod 'garden.core))))(deftask garden"compile garden"[o output-to PATH str "The output css file path relative to docroot."s styles-var SYM sym "The var containing garden rules"p pretty-print bool "Pretty print compiled CSS"v vendors [str] "Vendors to apply prefixed for"a auto-prefix [str] "Properties to auto-prefix with vendor-prefixes"]
;; ...;; (deftask garden;; "compile garden";; [o output-to PATH str "The output css file path relative to docroot.";; s styles-var SYM sym "The var containing garden rules";; p pretty-print bool "Pretty print compiled CSS";; v vendors [str] "Vendors to apply prefixed for";; a auto-prefix [str] "Properties to auto-prefix with vendor-prefixes"](let [output-path (or output-to "main.css")ns-sym (symbol (namespace styles-var))tmp (boot/temp-dir!)out (io/file tmp output-path)src-paths (vec (boot/get-env :source-paths))garden-pods (garden-pool)ns-pod (ns-tracker-pod)]
;; ...;; (let [output-path (or output-to "main.css");; ns-sym (symbol (namespace styles-var));; tmp (boot/temp-dir!);; out (io/file tmp output-path);; src-paths (vec (boot/get-env :source-paths));; garden-pods (garden-pool);; ns-pod (ns-tracker-pod)](pod/with-eval-in ns-pod(require 'ns-tracker.core)(def cns (ns-tracker.core/ns-tracker ~src-paths)))
;; ...;; (pod/with-eval-in ns-pod;; (require 'ns-tracker.core);; (def cns (ns-tracker.core/ns-tracker ~src-paths)))(boot/with-pre-wrap fileset(when (or @initial (some #{ns-sym} (pod/with-eval-in ns-pod (cns))))(let [c-pod (garden-pods :refresh)](if @initial (reset! initial false))(util/info "Compiling %s...\n" (.getName out))(io/make-parents out)
;; ...;; (boot/with-pre-wrap fileset;; (when (or @initial (some #{ns-sym} (pod/with-eval-in ns-pod (cns))));; (let [c-pod (garden-pods :refresh)];; (if @initial (reset! initial false));; (util/info "Compiling %s...\n" (.getName out));; (io/make-parents out)(pod/with-eval-in c-pod(require '~ns-sym)(garden.core/css {:output-to ~(.getPath out):pretty-print ~pretty-print:vendors ~vendors:auto-prefix ~(set auto-prefix)} ~css-var));))
;; ...;; (boot/with-pre-wrap fileset;; (when (or @initial (some #{ns-sym} (pod/with-eval-in ns-pod (cns))));; (let [c-pod (garden-pods :refresh)];; (if @initial (reset! initial false));; (util/info "Compiling %s...\n" (.getName out));; (io/make-parents out);; (pod/with-eval-in c-pod;; (require '~ns-sym);; (garden.core/css {:output-to ~(.getPath out);; :pretty-print ~pretty-print;; :vendors ~vendors;; :auto-prefix ~(set auto-prefix)} ~css-var));))(-> fileset (boot/add-resource tmp) boot/commit!);)))
Done!
RESOURCES
#HOPLON (IRC)
TENZINGlein new tenzing your-app
FAZIT
THANK YOU@martinklepsch
QUESTIONS?@martinklepsch