Allow :manifest entries to contain functions.

This commit is contained in:
Phil Hagelberg 2012-04-30 11:11:21 -07:00
parent d50a320b21
commit 0016f04e2e
2 changed files with 13 additions and 3 deletions

View file

@ -181,7 +181,13 @@
:bytes (:out (clojure.java.shell/sh
"git" "log" "-n" "1"))})}]
;; Set arbitrary key/value pairs for the jar's manifest.
:manifest {"Project-awesome-level" "super-great"}
:manifest {"Project-awesome-level" "super-great"
;; function values will be called with the project as an argument.
"Class-Path" ~#(clojure.string/join
java.io.File/pathSeparatorChar
(leiningen.core.classpath/get-classpath %))
;; symbol values will be resolved to find a function to call.
"Grunge-level" my.plugin/calculate-grunginess}
;; You can set JVM-level options here.
:jvm-opts ["-Xmx1g"]
;; Control the context in which your project code is evaluated.

View file

@ -84,12 +84,16 @@
"Built-By" (System/getProperty "user.name")
"Build-Jdk" (System/getProperty "java.version")})
(defn- manifest-entry [project manifest [k v]]
(cond (symbol? v) (manifest-entry project manifest [k (resolve v)])
(fn? v) (manifest-entry project manifest [k (v project)])
:else (str manifest "\n" (name k) ": " v)))
(defn ^:internal make-manifest [project]
(Manifest.
(ByteArrayInputStream.
(.getBytes
(reduce (fn [manifest [k v]]
(str manifest "\n" k ": " v))
(reduce (partial manifest-entry project)
"Manifest-Version: 1.0"
(merge default-manifest (:manifest project)
;; (when (:shell-wrapper project)