Browse Source

added build script (for uberjar)

Brandon Wong 1 year ago
parent
commit
2215cbd642
4 changed files with 30 additions and 2 deletions
  1. 1 0
      .gitignore
  2. 24 0
      build.clj
  3. 3 1
      deps.edn
  4. 2 1
      src/attendant/main.clj

+ 1 - 0
.gitignore

@@ -4,3 +4,4 @@
 .cpcache
 .nrepl-port
 .rebel_readline_history
+target

+ 24 - 0
build.clj

@@ -0,0 +1,24 @@
+(ns build
+  (:require [clojure.tools.build.api :as b]))
+
+(def lib 'attendant)
+(def version "0.0.1")
+
+(def class-dir "target/classes")
+(def basis (b/create-basis {:project "deps.edn"}))
+(def uber-file (format "target/%s-%s-standalone.jar" (name lib) version))
+
+(defn clean [_]
+  (b/delete {:path "target"}))
+
+(defn uber [_]
+  (clean nil)
+  (b/copy-dir {:src-dirs ["src"]
+               :target-dir class-dir})
+  (b/compile-clj {:basis basis
+                  :src-dirs ["src"]
+                  :class-dir class-dir})
+  (b/uber {:class-dir class-dir
+           :uber-file uber-file
+           :basis basis
+           :main 'attendant.main}))

+ 3 - 1
deps.edn

@@ -10,4 +10,6 @@
  :aliases {:dev {:extra-deps {ring/ring-devel {:mvn/version "1.9.5"}
                               ring/ring-mock {:mvn/version "0.4.0"}}
                  :extra-paths ["dev"]
-                 :main-opts ["-m" "user"]}}}
+                 :main-opts ["-m" "user"]}
+           :build {:deps {org.clojure/tools.build {:mvn/version "0.8.4"}}
+                   :ns-default build}}}

+ 2 - 1
src/attendant/main.clj

@@ -2,7 +2,8 @@
   (:require
    [com.stuartsierra.component :as component]
    [attendant.server :as server]
-   [attendant.nrepl-component :as nrepl]))
+   [attendant.nrepl-component :as nrepl])
+  (:gen-class))
 
 (def port 2424)