Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
A working bootstrap state!
Browse files Browse the repository at this point in the history
  • Loading branch information
arrdem committed Oct 15, 2018
1 parent 71991f7 commit 0fd3c1c
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 8 deletions.
1 change: 1 addition & 0 deletions deps-resolve.edn
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

instaparse/instaparse {:mvn/version"1.4.9"}
io.replikativ/hasch {:mvn/version "0.3.4"}
pandect/pandect {:mvn/version "0.6.1"}

me.raynes/fs {:mvn/version "1.4.6"}

Expand Down
2 changes: 1 addition & 1 deletion depstar/Rollfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
(deftarget healthfinch/depstar
(clojure-library
:paths ["src"]
:deps {org.clojure/clojure nil})
:deps {org.clojure/clojure nil}))
2 changes: 1 addition & 1 deletion kat
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fi

# Where do the cache, lockfiles and other state live
if [ -z "${KAT_SERVER_WORK_DIR}" ]; then
KAT_SERVER_WORK_DIR=$(_get_conf "${KAT_CONFIG}" server_work_dir)
KAT_SERVER_WORK_DIR="${KAT_REPO_ROOT}/"$(_get_conf "${KAT_CONFIG}" server_work_dir)
fi

## Booting the server
Expand Down
10 changes: 8 additions & 2 deletions kat.conf

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion katamari/Rollfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
ring/ring nil
ring/ring-jetty-adapter nil
ring/ring-json nil

compojure/compojure nil
cheshire/cheshire nil

healthfinch/depstar nil
pandect/pandect nil
instaparse/instaparse nil

;; Embedded development
Expand Down
46 changes: 44 additions & 2 deletions katamari/src/katamari/server/tasks/roll.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
[clojure.tools.deps.alpha.script.make-classpath :as mkcp]
[clojure.tools.deps.alpha.script.parse :as deps-parser]

;;katamari
;; Katamari
[katamari.roll.reader :refer [compute-buildgraph refresh-buildgraph-for-changes]]
[katamari.deps.extensions.roll :as der]

;; Ring
[ring.util.response :as resp]))
[ring.util.response :as resp]

[hf.depstar.uberjar :as ds])
(:import [java.nio.file Files]
[java.nio.file.attribute FileAttribute]))

;;;; Handlers

Expand Down Expand Up @@ -83,3 +87,41 @@
(resp/status 200))

(handler config stack request))))

(defn handle-uberjar
{:kat/request-name "uberjar"
:kat/doc "Produce an uberjar, according to the target's config"}
[handler]
(fn [config stack request]
(case (first request)
"meta"
(update (handler config stack request)
:body conj (meta #'handle-uberjar))

"uberjar"
(if-let [target (second request)]
(if-let [target-coord (get-in config [:buildgraph :targets (symbol target)])]
(let [classpath (-> (stack config stack (list "classpath" "--" target))
:body)
target-dir (fs/file (:repo-root config)
(:target-dir config))
jar-name (:jar-name target-coord (str (name (:name target-coord)) ".jar"))
jar-file (fs/file target-dir jar-name)
jar-path (.toPath jar-file)
msgs (with-out-str
(binding [*err* *out*]
(let [tmp (Files/createTempDirectory "uberjar" (make-array FileAttribute 0))]
(run! #(ds/copy-source % tmp {}) (str/split classpath #":"))
(ds/write-jar tmp jar-path))))]
(-> {:msg msgs
:jar-path (.getCanonicalPath jar-file)}
resp/response
(resp/status 200)))
(-> "Could not produce an uberjar, no target coordinate was loaded!"
resp/response
(resp/status 400)))
(-> "Could not produce an uberjar, no target provided!"
resp/response
(resp/status 400)))

(handler config stack request))))
1 change: 1 addition & 0 deletions katamari/src/katamari/server/web_server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
t.c/handle-stop-server

;; :thinking:
t.roll/handle-uberjar
t.roll/handle-classpath
t.roll/wrap-buildgraph

Expand Down
6 changes: 5 additions & 1 deletion katamari/src/katamari/targets/extensions/jvm.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
(s/def ::manifest
(s/map-of string? string?))

(s/def ::jar-name
string?)

(deftarget jarfile
(s/keys* :req-un [::rs/deps]
:opt-un [::entry-point
:opt-un [::jar-name
::entry-point
::manifest]))

0 comments on commit 0fd3c1c

Please sign in to comment.