diff --git a/sample.project.clj b/sample.project.clj index b8658446..b8982292 100644 --- a/sample.project.clj +++ b/sample.project.clj @@ -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 diff --git a/src/leiningen/deps.clj b/src/leiningen/deps.clj index 6a25c740..19e6d51c 100644 --- a/src/leiningen/deps.clj +++ b/src/leiningen/deps.clj @@ -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] diff --git a/src/leiningen/util/maven.clj b/src/leiningen/util/maven.clj index 591e651d..82bf74db 100644 --- a/src/leiningen/util/maven.clj +++ b/src/leiningen/util/maven.clj @@ -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.)]