Permalink
Browse files

Allow :manifest entries to contain functions.

  • Loading branch information...
1 parent d50a320 commit 0016f04e2ebb190c44883b952a60036ebbeb5708 @technomancy committed Apr 30, 2012
Showing with 13 additions and 3 deletions.
  1. +7 −1 sample.project.clj
  2. +6 −2 src/leiningen/jar.clj
View
@@ -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
@@ -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)

0 comments on commit 0016f04

Please sign in to comment.