Skip to content

Commit

Permalink
native clj building
Browse files Browse the repository at this point in the history
  • Loading branch information
port19x committed Dec 26, 2022
1 parent e58d246 commit eb35bfa
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
31 changes: 31 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(ns build
(:require [clojure.tools.build.api :as b]))

(def build-folder "target")
(def jar-content (str build-folder "/classes"))

(def basis (b/create-basis {:project "deps.edn"}))
(def version "1.0")
(def app-name "redqu")
(def uber-file-name (format "%s/%s-%s.jar" build-folder app-name version)) ; path for result uber file

(defn clean [_]
(b/delete {:path "target"})
(println (format "Build folder \"%s\" removed" build-folder)))

(defn uber [_]
(clean nil)

(b/copy-dir {:src-dirs ["resources"] ; copy resources
:target-dir jar-content})

(b/compile-clj {:basis basis ; compile clojure code
:src-dirs ["src"]
:class-dir jar-content})

(b/uber {:class-dir jar-content ; create uber file
:uber-file uber-file-name
:basis basis
:main 'redqu.core}) ; here we specify the entry point for uberjar

(println (format "Uber file created: \"%s\"" uber-file-name)))
9 changes: 7 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{:deps {org.clojure/clojure {:mvn/version "1.11.1"}
clj-http {:mvn/version "3.12.3"}
clj-http/clj-http {:mvn/version "3.12.3"}
org.clojure/tools.build {:mvn/version "0.9.0"}
org.clojure/tools.cli {:mvn/version "1.0.214"}}
:paths ["src"]
}
:aliases
{
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.8.1" :git/sha "7d40500"}}
:ns-default build}} ; <-- set build namespace as default
}

0 comments on commit eb35bfa

Please sign in to comment.