Created
September 9, 2016 15:05
-
-
Save telent/7f7a4641260bb453947f0e61ea6c0d57 to your computer and use it in GitHub Desktop.
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
;; As of September 2016, using the version of boot-clj that I got by following the Nix install instructions, | |
;; here is how I built a clojure "hello world" as a uberjar that you can run with `java -jar`. I do | |
;; not claim it is the right way, merely that it worked for me. This file is build.boot | |
(set-env! | |
:resource-paths #{"src"} ; may be optional? | |
:source-paths #{"src"} ; my code is in src/myapp/core.clj | |
:dependencies '[[org.clojure/clojure "1.8.0"]]) ; not sure I'm actually using this, boot may be overriding it | |
(task-options! | |
; these are default arguments that are merged in whenever their respective tasks are called | |
pom {:project 'myapp ; this is java magic and i don't know why I'm doing it | |
:version "0.1.0"} | |
jar {:main 'myapp.core} | |
target {:dir #{"target/"}}) | |
; these are the tasks which I want to run | |
(deftask build [] | |
(comp | |
(aot :namespace #{'myapp.core}) ; I *think* this is needed to get a .class file for this ns into the jar | |
(pom) | |
(uber) ; unpacks all the dependencies into the output fileset | |
(jar) ; the file this creates is called "project.jar" no matter what the project was called | |
(sift :include #{#"project.jar$"}) ; remove all the other files in the output fileset | |
;; requirement for the following step seems to have been added quite recently as I don't see it mentioned | |
;; in many web examples. without it you will not get the target/ directory and will never be able to find | |
;; the generated example | |
(target) ; save the output fileset | |
(install) ; I thnk this also puts stuff in your local maven (may be able to skip this) | |
)) |
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 is src/myapp/core.clj | |
(ns myapp.core (:gen-class)) ; gen-class is important | |
(defn -main [] | |
(println "hello world")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Impressions of boot as a new user:
(target)
:gen-class
but I always forget that with leiningen too, so not boot's faultTo get the example to work, run
I have not (knowingly) used any plugins or middlewares or any other libraries here.