-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from parenthesin/refact/using-tools-build
refact: using tools.build to pack uberjar
- Loading branch information
Showing
4 changed files
with
50 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(ns build | ||
(:refer-clojure :exclude [test]) | ||
(:require [clojure.tools.build.api :as b])) | ||
|
||
(def default-lib 'com.github.parenthesin/microservice-boilerplate-malli) | ||
(def default-main 'microservice-boilerplate.server) | ||
(def default-version "0.0.1-SNAPSHOT") | ||
(def class-dir "target/classes") | ||
|
||
(defn- uber-opts [{:keys [lib main uber-file version] :as opts}] | ||
(let [actual-lib (or lib default-lib) | ||
actual-main (or main default-main) | ||
actual-version (or version default-version) | ||
actual-uber-file (or uber-file (format "target/%s-%s.jar" | ||
actual-lib | ||
actual-version))] | ||
(assoc opts | ||
:lib actual-lib | ||
:main actual-main | ||
:uber-file actual-uber-file | ||
:basis (b/create-basis {}) | ||
:class-dir class-dir | ||
:src-dirs ["src"] | ||
:ns-compile [actual-main]))) | ||
|
||
(defn uberjar "Build the Uberjar." [opts] | ||
(b/delete {:path "target"}) | ||
(let [{:keys [main uber-file] :as opts} (uber-opts opts)] | ||
(println "\nCopying source" class-dir) | ||
(b/copy-dir {:src-dirs ["resources" "src"] :target-dir class-dir}) | ||
(println (str "\nCompiling " main)) | ||
(b/compile-clj opts) | ||
(println "\nBuilding JAR on" uber-file) | ||
(b/uber opts)) | ||
opts) |
This file contains 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