Permalink
Browse files

Added lein ring uberjar task

  • Loading branch information...
weavejester committed Dec 11, 2012
1 parent 322435f commit 8722156814bf2c0be54a81025917f116a7afa2b4
View
@@ -3,6 +3,7 @@
[leiningen.ring.server :only (server)]
[leiningen.ring.server-headless :only (server-headless)]
[leiningen.ring.jar :only (jar)]
+ [leiningen.ring.uberjar :only (uberjar)]
[leiningen.ring.war :only (war)]
[leiningen.ring.uberwar :only (uberwar)]))
@@ -23,6 +24,7 @@
"server" (apply server project args)
"server-headless" (apply server-headless project args)
"jar" (apply jar project args)
+ "uberjar" (apply uberjar project args)
"war" (apply war project args)
"uberwar" (apply uberwar project args)
(println "Subtask" (str \" subtask \") "not found."
@@ -1,5 +1,5 @@
(ns leiningen.ring.jar
- (:use [leiningen.ring.util :only (compile-form ensure-handler-set!)]
+ (:use [leiningen.ring.util :only (compile-form ensure-handler-set! update-project)]
[leiningen.ring.server :only (add-server-dep)])
(:require [clojure.string :as str]
leiningen.jar))
@@ -22,11 +22,6 @@
(ring.server.leiningen/serve
'~(select-keys project [:ring])))))))
-(defn update-project [project func & args]
- (vary-meta
- (apply func project args)
- update-in [:without-profiles] #(apply func % args)))
-
(defn add-main-class [project]
(update-project project assoc :main (symbol (main-namespace project))))
@@ -1,7 +1,7 @@
(ns leiningen.ring.server
(:require [leinjacker.deps :as deps])
(:use [leinjacker.eval :only (eval-in-project)]
- leiningen.ring.util))
+ [leiningen.ring.util :only (ensure-handler-set! update-project)]))
(defn load-namespaces
"Create require forms for each of the supplied symbols. This exists because
@@ -14,7 +14,7 @@
s))))
(defn add-server-dep [project]
- (deps/add-if-missing project '[ring-server "0.2.5"]))
+ (update-project project deps/add-if-missing '[ring-server "0.2.5"]))
(defn server-task
"Shared logic for server and server-headless tasks."
@@ -0,0 +1,11 @@
+(ns leiningen.ring.uberjar
+ (:use [leiningen.ring.util :only (ensure-handler-set!)]
+ [leiningen.ring.server :only (add-server-dep)])
+ (:require [leiningen.ring.jar :as jar]
+ leiningen.uberjar))
+
+(defn uberjar [project]
+ (ensure-handler-set! project)
+ (let [project (-> project add-server-dep jar/add-main-class)]
+ (jar/compile-main project)
+ (leiningen.uberjar/uberjar project)))
@@ -38,3 +38,10 @@
(eval-in-project project
`(do (clojure.core/compile '~namespace) nil)
nil))
+
+(defn update-project
+ "Update the project map using a function."
+ [project func & args]
+ (vary-meta
+ (apply func project args)
+ update-in [:without-profiles] #(apply func % args)))

0 comments on commit 8722156

Please sign in to comment.