Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

uberjar fixes for cake releasing cake

  • Loading branch information...
commit 5344c5f3410317f592ee2d5cd7d4cb67a628cbfa 1 parent 9ae704f
@ninjudd authored
Showing with 35 additions and 30 deletions.
  1. +19 −15 src/cake/tasks/jar.clj
  2. +16 −15 tasks.clj
View
34 src/cake/tasks/jar.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,8 +126,7 @@
(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")]
@@ -131,6 +134,7 @@
(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}
View
31 tasks.clj
@@ -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 [org.apache.tools.ant.taskdefs Jar Copy Move ExecTask]
[java.io 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"})
add-dev-jars)
- (ant Jar {:dest-file (jarfile) :update true}
+ (ant Jar {:dest-file jar :update true}
add-dev-jars)))
(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")))))
Please sign in to comment.
Something went wrong with that request. Please try again.