diff --git a/sample.project.clj b/sample.project.clj index 378ed0b6..7b317a69 100644 --- a/sample.project.clj +++ b/sample.project.clj @@ -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. diff --git a/src/leiningen/jar.clj b/src/leiningen/jar.clj index 2d53b1b6..1ba32e3b 100644 --- a/src/leiningen/jar.clj +++ b/src/leiningen/jar.clj @@ -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))))))