Skip to content

Commit

Permalink
Add global :exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
joegallo committed Mar 11, 2011
1 parent 90aad00 commit ac9f135
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
4 changes: 4 additions & 0 deletions sample.project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
;; development. Projects that depend on this project will not pull
;; in its dev-dependencies, and they won't be included in the uberjar.
:dev-dependencies [[org.clojure/swank-clojure "1.2.1"]]
;; Global exclusions are applied across the board, as an alternative
;; to duplication for multiple depedencies with the same excluded libraries.
:exclusions [org.apache.poi/poi
org.apache.poi/poi-ooxml]
;; Only re-fetch dependencies when they change in project.clj or
;; when :library-path directory is empty.
:checksum-deps true
Expand Down
2 changes: 1 addition & 1 deletion src/leiningen/deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
(doseq [repo (make-repositories project)]
(.addConfiguredRemoteRepository deps-task repo))
(doseq [dep (project deps-set)]
(.addDependency deps-task (make-dependency dep)))
(.addDependency deps-task (make-dependency project dep)))
deps-task))

(defn use-dev-deps? [project skip-dev]
Expand Down
43 changes: 23 additions & 20 deletions src/leiningen/util/maven.clj
Original file line number Diff line number Diff line change
Expand Up @@ -145,26 +145,29 @@ the :classifier key (if present) is the classifier on the
dependency (as a string). The value for the :exclusions key, if
present, is a seq of symbols, identifying group ids and artifact ids
to exclude from transitive dependencies."
[dependency]
(when-not (vector? dependency)
(abort "Dependencies must be specified as vector:" dependency))
(let [[dep version & extras] dependency
extras-map (apply hash-map extras)
exclusions (:exclusions extras-map)
classifier (:classifier extras-map)
type (:type extras-map)
es (map make-exclusion exclusions)]
(doto (Dependency.)
;; Allow org.clojure group to be omitted from clojure/contrib deps.
(.setGroupId (if (and (nil? (namespace dep))
(re-find #"^clojure(-contrib)?$" (name dep)))
"org.clojure"
(or (namespace dep) (name dep))))
(.setArtifactId (name dep))
(.setVersion version)
(.setClassifier classifier)
(.setType (or type "jar"))
(.setExclusions es))))
([dependency]
(make-dependency {} dependency))
([project dependency]
(when-not (vector? dependency)
(abort "Dependencies must be specified as vector:" dependency))
(let [[dep version & extras] dependency
extras-map (apply hash-map extras)
exclusions (:exclusions extras-map)
classifier (:classifier extras-map)
type (:type extras-map)
es (map make-exclusion (concat exclusions
(:exclusions project)))]
(doto (Dependency.)
;; Allow org.clojure group to be omitted from clojure/contrib deps.
(.setGroupId (if (and (nil? (namespace dep))
(re-find #"^clojure(-contrib)?$" (name dep)))
"org.clojure"
(or (namespace dep) (name dep))))
(.setArtifactId (name dep))
(.setVersion version)
(.setClassifier classifier)
(.setType (or type "jar"))
(.setExclusions es)))))

(defn make-repository [[id settings]]
(let [repo (Repository.)]
Expand Down

0 comments on commit ac9f135

Please sign in to comment.