Browse files

uberjar fixes for cake releasing cake

  • Loading branch information...
1 parent 9ae704f commit 5344c5f3410317f592ee2d5cd7d4cb67a628cbfa @ninjudd committed Sep 13, 2011
Showing with 35 additions and 30 deletions.
  1. +19 −15 src/cake/tasks/jar.clj
  2. +16 −15 tasks.clj
@@ -75,20 +75,24 @@
(add-fileset task {:file (build-context (current-context))})
(add-zipfileset task (bakepath opts :excludes "cake.clj"))))
+(defn meta-inf [prefix]
+ (format "META-INF/%s/%s/%s" prefix (:group-id *project*) (:artifact-id *project*)))
+(defn add-meta-inf [task]
+ (add-zipfileset task {:dir (file ".") :prefix (meta-inf "maven") :includes "pom.xml"})
+ (add-zipfileset task {:dir (file ".") :prefix (meta-inf "cake") :includes "*.clj"}))
(defn build-jar []
- (let [[maven cake] (for [tool '[maven cake]]
- (format "META-INF/%s/%s/%s" tool (:group-id *project*) (:artifact-id *project*)))]
- (ant Jar {:dest-file (jarfile)}
- (add-manifest (manifest))
- (add-license)
- (add-source-files)
- (add-path :compile-path {:includes "**/*.class"})
- (add-path :resources-path)
- (add-zipfileset {:dir (file ".") :prefix maven :includes "pom.xml"})
- (add-zipfileset {:dir (file ".") :prefix cake :includes "*.clj"})
- (add-fileset {:dir (file "build" "jar")})
- (add-zipfileset {:dir (file "native") :prefix "native"})
- (add-file-mappings (:jar-files *project*)))))
+ (ant Jar {:dest-file (jarfile)}
+ (add-manifest (manifest))
+ (add-license)
+ (add-meta-inf)
+ (add-source-files)
+ (add-path :compile-path {:includes "**/*.class"})
+ (add-path :resources-path)
+ (add-fileset {:dir (file "build" "jar")})
+ (add-zipfileset {:dir (file "native") :prefix "native"})
+ (add-file-mappings (:jar-files *project*))))
(defn clean [pattern]
(when (:clean *opts*)
@@ -122,15 +126,15 @@
(defn add-jar-contents [task jars]
(doseq [jar jars :let [name (.replace (.getName (file jar)) ".jar" "")]]
- (add-zipfileset task {:src jar :excludes "META-INF/**/*, project.clj, LICENSE"})
- (add-zipfileset task {:src jar :includes "META-INF/**/*" :prefix (str "META-INF/" name)})))
+ (add-zipfileset task {:src jar :excludes "META-INF/**, project.clj, LICENSE"})))
(defn build-uberjar [jarfile jars]
(let [plexus-components (file "build/uberjar/META-INF/plexus/components.xml")]
(merge-plexus-components jars plexus-components)
(ant Jar {:dest-file jarfile :duplicate "preserve"}
(add-manifest (manifest))
(add-jar-contents jars)
+ (add-meta-inf)
(add-fileset {:dir (file "build" "uberjar")}))))
(deftask uberjar #{jar}
@@ -2,7 +2,7 @@
(:use cake cake.core cake.file uncle.core
[cake.utils :only [git]]
[bake.core :only [log]]
- [cake.tasks.jar :only [build-uberjar jars jarfile]]
+ [cake.tasks.jar :only [build-uberjar jars uberjarfile]]
[cake.tasks.version :only [snapshot? stable?]])
(:import [ Jar Copy Move ExecTask]
[ File]))
@@ -20,25 +20,26 @@
(undeftask uberjar)
(deftask uberjar #{jar}
"Create a standalone jar containing all project dependencies."
- (let [jar (jarfile)]
- (build-uberjar jar (remove clojure-jar? (rest (jars))))
+ (let [jar (uberjarfile)]
+ (build-uberjar jar (remove clojure-jar? (jars)))
(ant Jar {:dest-file (bakejar)}
(add-fileset {:dir "dev"})
- (ant Jar {:dest-file (jarfile) :update true}
+ (ant Jar {:dest-file jar :update true}
(undeftask release)
(deftask release #{uberjar tag}
"Release project jar to github"
- (when-not (snapshot? (:version *project*))
- (with-root (file "releases")
- (git "pull"))
- (ant Copy {:file (jarfile) :todir (file "releases" "jars")})
- (ant Copy {:file (bakejar) :todir (file "releases" "jars")})
- (when (stable? (:version *project*))
- (ant Copy {:file (file "bin" "cake") :tofile (file "releases" "cake")}))
- (with-root (file "releases")
- (git "add" "jars" "cake")
- (git "commit" "--allow-empty" "-m" (format "'release cake %s'" (:version *project*)))
- (git "push"))))
+ (let [version (:version *project*)]
+ (when-not (snapshot? version)
+ (with-root (file "releases")
+ (git "pull"))
+ (ant Copy {:file (uberjarfile) :tofile (file "releases" "jars" (format "cake-%s.jar" version))})
+ (ant Copy {:file (bakejar) :todir (file "releases" "jars")})
+ (when (stable? version)
+ (ant Copy {:file (file "bin" "cake") :tofile (file "releases" "cake")}))
+ (with-root (file "releases")
+ (git "add" "jars" "cake")
+ (git "commit" "--allow-empty" "-m" (format "'release cake %s'" (:version *project*)))
+ (git "push")))))

0 comments on commit 5344c5f

Please sign in to comment.