Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

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

  • Loading branch information...
commit acc9a828e5f2ef8cffb172fadca3e1498c53aa8b 1 parent ceec0be
@technomancy authored
Showing with 8 additions and 5 deletions.
  1. +2 −0  sample.project.clj
  2. +6 −5 src/leiningen/jar.clj
2  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.
11 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))))))
Please sign in to comment.
Something went wrong with that request. Please try again.