| (ns immutant.boot-immutant | |
| (:require [boot.core :as boot :refer [deftask]] | |
| [boot.pod :as pod] | |
| [boot.task.built-in :as built-in] | |
| [boot.tmpdir :as tmpd] | |
| [clojure.java.io :as io] | |
| [clojure.set :as set] | |
| [clojure.string :as str] | |
| [immutant.deploy-tools.war :as war] | |
| [cemerick.pomegranate.aether :as aether] | |
| boot.aether)) | |
| (defn gen-classpath [{:keys [source-paths resource-paths] :as env}] | |
| (into (mapv #(-> % io/file .getAbsolutePath) (concat source-paths resource-paths)) | |
| (pod/with-call-worker | |
| (boot.aether/resolve-dependency-jars ~env)))) | |
| (defonce ^:private pod | |
| (pod/make-pod {:dependencies [['org.immutant/deploy-tools "2.0.5-SNAPSHOT"] | |
| ['boot/aether "2.0.0-rc14"]]})) | |
| (defn gen-uberjar [] | |
| (let [fname "app-uber.jar"] | |
| (boot/boot (built-in/uber) (built-in/jar :file fname)) | |
| (doto (io/file (str "target/" fname)) | |
| (.deleteOnExit)))) | |
| (deftask war | |
| "Creates an Immutant war." | |
| [i init-fn FN sym "The 'main' function to call on deploy" | |
| d dev bool "Generate a 'dev' war" | |
| c context-path PATH str "Deploy to this context path" | |
| v virtual-host HOST [str] "Deploy to the named host defined in the WildFly config" | |
| o destination DIR str "Write the generated war to DIR" | |
| n name NAME str "Override the name of the war (sans the .war suffix)" | |
| r resource-path PATH [str] "Paths to file trees to include in the top level of the war" | |
| _ nrepl-host HOST str "Host for nrepl to bind to" | |
| _ nrepl-port PORT int "Port for nrepl to bind to" | |
| _ nrepl-port-file FILE file "File to write actual nrepl port to" | |
| _ nrepl-start bool "Request nrepl to start (default for 'dev' wars)"] | |
| ;; TODO: defaults for init-fn (with warn), name?, nrepl | |
| ;; stuffs. also, a way to set nrepl options? | |
| ;; TODO: notify when complete | |
| (boot/with-pre-wrap fileset | |
| (let [env (boot/get-env) | |
| classpath (when dev (gen-classpath env)) | |
| uberjar (when-not dev (gen-uberjar))] | |
| (pod/with-eval-in pod | |
| (require | |
| '[immutant.deploy-tools.war :as war] | |
| '[cemerick.pomegranate.aether :as aether] | |
| '[clojure.java.io :as io]) | |
| (let [dest-path | |
| (.getAbsolutePath | |
| (io/file (or (war/resolve-target-path ~destination) "target") | |
| (str (or ~name "app") ".war")))] | |
| (war/create-war | |
| dest-path | |
| (merge ~env | |
| {:init-fn ~init-fn | |
| :root (System/getProperty "user.dir") ;; FIXME: is this correct? | |
| :dependency-resolver #(map io/file (boot.aether/resolve-dependency-jars %)) | |
| :dependency-hierarcher #(aether/dependency-hierarchy (:dependencies %) | |
| (boot.aether/resolve-dependencies* ~env)) | |
| :dev? ~dev | |
| :context-path ~context-path | |
| :virtual-host ~virtual-host | |
| :nrepl {:port ~nrepl-port | |
| :host ~nrepl-host | |
| :start? ~nrepl-start | |
| :port-file ~nrepl-port-file | |
| :options nil} | |
| :classpath ~classpath | |
| :uberjar ~uberjar}))))) | |
| fileset)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment