Specify what file patterns to exclude from jars. Thanks to Zehua Liu.

This commit is contained in:
Phil Hagelberg 2010-09-23 22:45:57 -07:00
parent ceec0be5a6
commit acc9a828e5
2 changed files with 8 additions and 5 deletions

View file

@ -85,6 +85,8 @@
:uberjar-name "sample-standalone.jar" ; as above for uberjar
;; Leave the contents of :source-path out of jars (for AOT projects)
:omit-source true
;; Files with names matching any of these patterns will be excluded from jars
:jar-exclusions [#"(?:^|/).svn/"]
;; Set arbitrary key/value pairs for the jar's manifest.
:manifest {"Project-awesome-level" "super-great"}
;; You can set JVM-level options here.

View file

@ -74,10 +74,11 @@
(defn- unix-path [path]
(.replaceAll path "\\\\" "/"))
(defn- skip-file? [file]
(defn- skip-file? [file relative-path patterns]
(or (.isDirectory file)
(re-find #"^\.?#" (.getName file))
(re-find #"~$" (.getName file))))
(re-find #"~$" (.getName file))
(reduce #(or %1 (re-find %2 relative-path)) false patterns)))
(defmulti ^:private copy-to-jar (fn [project jar-os spec] (:type spec)))
@ -90,9 +91,9 @@
[resources classes src]
(map noroot (map project [:resources-path :compile-path :source-path]))]
(doseq [child (file-seq (file (:path spec)))]
(when-not (skip-file? child)
(let [path (reduce trim-leading-str (unix-path (str child))
[root resources classes src "/"])]
(let [path (reduce trim-leading-str (unix-path (str child))
[root resources classes src "/"])]
(when-not (skip-file? child path (:jar-exclusions project))
(.putNextEntry jar-os (doto (JarEntry. path)
(.setTime (.lastModified child))))
(copy child jar-os))))))