Created
September 3, 2015 18:46
-
-
Save Deraen/716ed7d856e3099d438c to your computer and use it in GitHub Desktop.
Multiple modules Boot project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(task-options! | |
pom {:project 'metosin/palikka | |
:version "0.1.0-SNAPSHOT"}) | |
(def modules | |
{:core {} | |
:database {:dependencies '[[hikari-cp "1.2.4"]]} | |
:flyway {:dependencies '[[org.flywaydb/flyway-core "3.2.1"]]} | |
:http-kit {:dependencies '[[http-kit "2.1.19"]]} | |
:mongo {:dependencies '[[com.novemberain/monger "2.1.0"]]} | |
:env {:dependencies '[[metosin/maailma "0.1.0-SNAPSHOT"]]}}) | |
(set-env! | |
:resource-paths (into #{"src/core"} (map (comp #(str "src/" %) name key) modules)) | |
:dependencies '[[org.clojure/clojure "1.7.0" :scope "test"] | |
[prismatic/schema "0.4.4"] | |
[metosin/schema-tools "0.4.3"] | |
[com.stuartsierra/component "0.2.3"]]) | |
(defn filter-fileset [fileset p] | |
(update | |
fileset :tree | |
(fn [tree] | |
(reduce-kv (fn [tree path x] | |
(if (p path) | |
(assoc tree path x) | |
tree)) | |
(empty tree) | |
tree)))) | |
(deftask build-module | |
[m module MODULE kw ""] | |
(comp | |
(let [pom-middleware (pom :project (if (#{:core} module) | |
'metosin/palikka | |
(symbol (str "metosin/palikka." (name module)))))] | |
(fn [next-handler] | |
(fn [fileset] | |
(let [deps (get-env :dependencies) | |
restore-deps-handler (fn [fileset] | |
(println "restore-deps" module) | |
(set-env! :dependencies deps) | |
(next-handler fileset)) | |
pom-handler (pom-middleware restore-deps-handler)] | |
(println "set-deps" module) | |
(set-env! :dependencies #(into % (:dependencies (get modules module)))) | |
(pom-handler fileset))))) | |
(let [jar-middleware (jar)] | |
(fn [next-handler] | |
(fn [fileset] | |
(let [fileset' fileset | |
merge-fileset-handler (fn [fileset] | |
(println "merge fileset" module) | |
(next-handler (update fileset :tree #(merge (:tree fileset') %)))) | |
jar-handler (jar-middleware merge-fileset-handler)] | |
(println "filter fileset" module) | |
(jar-handler (filter-fileset fileset (fn [path] | |
; FIXME: | |
(re-matches (re-pattern (str ".*" (name module) ".*")) path)))))))) | |
(install))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❯ boot build-module -m mongo build-module -m http-kit | |
set-deps :mongo | |
Writing pom.xml and pom.properties... | |
restore-deps :mongo | |
filter fileset :mongo | |
Writing palikka.mongo-0.1.0-SNAPSHOT.jar... | |
merge fileset :mongo | |
Installing palikka.mongo-0.1.0-SNAPSHOT.jar... | |
set-deps :http-kit | |
Writing pom.xml and pom.properties... | |
restore-deps :http-kit | |
filter fileset :http-kit | |
Writing palikka.http-kit-0.1.0-SNAPSHOT.jar... | |
merge fileset :http-kit | |
Installing palikka.mongo-0.1.0-SNAPSHOT.jar... | |
clojure.lang.ExceptionInfo: java.io.FileNotFoundException: /home/juho/.boot/cache/tmp/home/juho/Source/metosin/palikka/f32/4ursa7/palikka.mongo-0.1.0-SNAPSHOT.jar (No such file or directory) | |
data: {:file "/tmp/boot.user4029630311022605566.clj", :line 33} | |
java.util.concurrent.ExecutionException: java.io.FileNotFoundException: /home/juho/.boot/cache/tmp/home/juho/Source/metosin/palikka/f32/4ursa7/palikka.mongo-0.1.0-SNAPSHOT.jar (No such file or directory) | |
java.io.FileNotFoundException: /home/juho/.boot/cache/tmp/home/juho/Source/metosin/palikka/f32/4ursa7/palikka.mongo-0.1.0-SNAPSHOT.jar (No such file or directory) | |
... | |
boot.pod/pom-properties pod.clj: 103 | |
boot.aether/install aether.clj: 160 | |
... | |
clojure.core/apply core.clj: 630 | |
boot.pod/eval-fn-call pod.clj: 184 | |
boot.pod/call-in* pod.clj: 191 | |
... | |
boot.pod/call-in* pod.clj: 194 | |
boot.task.built-in/fn/fn/fn/fn built_in.clj: 684 | |
boot.user/eval288/fn/fn/fn/merge-fileset-handler boot.user4029630311022605566.clj: 25 | |
boot.task.built-in/fn/fn/fn/fn built_in.clj: 603 | |
boot.user/eval288/fn/fn/fn boot.user4029630311022605566.clj: 25 | |
boot.user/eval288/fn/fn/fn/restore-deps-handler boot.user4029630311022605566.clj: 25 | |
boot.task.built-in/fn/fn/fn/fn built_in.clj: 297 | |
boot.user/eval288/fn/fn/fn boot.user4029630311022605566.clj: 25 | |
boot.task.built-in/fn/fn/fn/fn built_in.clj: 674 | |
boot.user/eval288/fn/fn/fn/merge-fileset-handler boot.user4029630311022605566.clj: 25 | |
boot.task.built-in/fn/fn/fn/fn built_in.clj: 603 | |
boot.user/eval288/fn/fn/fn boot.user4029630311022605566.clj: 25 | |
boot.user/eval288/fn/fn/fn/restore-deps-handler boot.user4029630311022605566.clj: 25 | |
boot.task.built-in/fn/fn/fn/fn built_in.clj: 297 | |
boot.user/eval288/fn/fn/fn boot.user4029630311022605566.clj: 25 | |
boot.core/run-tasks core.clj: 695 | |
boot.core/boot/fn core.clj: 705 | |
clojure.core/binding-conveyor-fn/fn core.clj: 1916 | |
... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment