Codebase list leiningen-clojure / 2da05e6
Add profile metadata Adds :leaky and :pom-scope metadata for profiles. The :dev, :test, :base and :provided profiles are implemented in terms of these. Profiles with :leaky metadata affect the pom and jar creation. Profiles with a :pom-scope metadata of :test or :provided also affect the dependencies of a pom. Hugo Duncan 9 years ago
8 changed file(s) with 269 addition(s) and 137 deletion(s). Raw diff Collapse all Expand all
8080 The profiles listed above are active during development, but they are
8181 unmerged before the jar and pom files are created, making them
8282 invisible to code that depends upon your project. The next two
83 profiles are different.
83 profile is different.
8484
8585 The `:provided` profile is used to specify dependencies that should be
8686 available during jar creation, but not propagated to other code that
9090 used for frameworks like Hadoop that provide their own copies of
9191 certain libraries.
9292
93 ## Default Profiles
94
95 The `:default-profile` specifies the profiles that are active by
96 default when running lein tasks. If not overridden, this is set to
97 `:core-default`, which is a composite profile with
98 `[:base :system :user :provided :dev]`.
99
93100 ## Task Specific Profiles
94101
95102 Some tasks automatically merge a profile if specified. Examples of
96103 these are the `:test` profile, when running the `test` task, and the
97104 `:repl` profile, when running the `repl` task.
105
106 ## Profile Metadata
107
108 If you mark your profile with `^:leaky` metadata, then the profile
109 will affect the generated pom and jar when active.
110
111 If you mark a profile with `^{:pom-scope :test}` metadata, then the
112 profile's `:dependencies` will be added with a `test` scope in the
113 generated pom and jar when active.
114
115 If you mark a profile with `^{:pom-scope :provided}` metadata, then the
116 profile's `:dependencies` will be added with a `provided` scope in the
117 generated pom and jar when active.
98118
99119 ## Merging
100120
468468 (def default-profiles
469469 "Profiles get merged into the project map. The :dev, :provided, and :user
470470 profiles are active by default."
471 (atom {:default [:base :system :user :provided :dev]
471 (atom {:default [:core-default]
472 :core-default [:base :system :user :provided :dev]
472473 :base {:resource-paths ["dev-resources"]
473474 :jvm-opts (with-meta tiered-jvm-opts
474475 {:displace true})
492493 :offline {:offline? true}
493494 :debug {:debug true}}))
494495
496 (def default-profile-metadata
497 {:dev {:pom-scope :test}
498 :test {:pom-scope :test}
499 :base {:pom-scope :test}
500 :provided {:pom-scope :provided}})
501
495502 (defn- meta-merge
496503 "Recursively merge values based on the information in their metadata."
497504 [left right]
749756 (vary-meta project assoc
750757 :profiles profiles))
751758
759 (defn- apply-profile-meta [default-meta profile]
760 (if (map? profile)
761 (let [profile (vary-meta profile (fn [m] (merge default-meta m)))]
762 (if-let [scope (:pom-scope (meta profile))]
763 (with-meta
764 (update-in profile [:dependencies]
765 (fn [deps]
766 (map
767 (fn [dep]
768 (if (some #(= :scope %) dep)
769 dep
770 (-> dep (conj :scope) (conj (name scope)))))
771 deps)))
772 (meta profile))
773 profile))
774 profile))
775
752776 (defn project-with-profiles [project]
753 (project-with-profiles-meta project (merge (read-plugin-profiles project)
754 (read-profiles project))))
777 (let [profiles (merge (read-plugin-profiles project)
778 (read-profiles project))]
779 (project-with-profiles-meta
780 project
781 (->> (map (fn [[k p]]
782 [k (apply-profile-meta (default-profile-metadata k) p)])
783 profiles)
784 (into {})))))
755785
756786 (defn ^:internal init-profiles
757787 "Compute a fresh version of the project map, including and excluding the
842872 merge profiles-map)})
843873 (vary-meta update-in [:profiles] merge profiles-map)))
844874
875 (defn included-profiles
876 "Return a sequence of keywords for the profiles in :included-profiles."
877 [project]
878 (-> project meta :included-profiles))
879
880 (defn profile-annotations
881 "Return a map of profile keyword to profile annotations for the profiles
882 in :include-profiles."
883 [project]
884 (->> (map
885 (juxt identity (comp meta (-> project meta :profiles)))
886 (included-profiles project))
887 (into {})
888 ;; (merge-with merge default-profile-metadata)
889 ))
890
891 (defn non-leaky-profiles
892 "Return a sequence of profile keywords for the non-leaky profiles
893 currently included in the project."
894 [project]
895 (->> (profile-annotations project)
896 (remove (comp :leaky val))
897 (map key)))
898
899 (defn pom-scope-profiles
900 "Return a sequence of profile keywords for the currently active
901 project profiles with :pom-scope equal to scope."
902 [project scope]
903 (->> (profile-annotations project)
904 (filter (comp #(= scope (:pom-scope %)) val))
905 keys))
906
845907 (defn read-raw
846908 "Read project file without loading certificates, plugins, middleware, etc."
847909 [file]
4141 [robert/hooke "1.1.2"]
4242 [stencil/stencil "0.2.0"]
4343 [org.clojure/tools.nrepl "0.2.5"
44 :exclusions [[org.clojure/clojure]]]
44 :exclusions [[org.clojure/clojure]]
45 :scope "test"]
4546 [clojure-complete/clojure-complete "0.2.3"
46 :exclusions [[org.clojure/clojure]]]],
47 :exclusions [[org.clojure/clojure]]
48 :scope "test"]],
4749 :twelve 12 ; testing unquote
4850
4951 :repositories [["central" {:url "https://repo1.maven.org/maven2/"
244244 (add-main main)))
245245
246246 (defn- preprocess-project [project & [main]]
247 (process-project project main project/unmerge-profiles [:default]))
247 (process-project project main project/unmerge-profiles
248 (project/non-leaky-profiles project)))
248249
249250 (defn- get-jar-filename*
250251 [project uberjar?]
303304 (when (:auto-clean project true)
304305 (clean/clean project))
305306 (eval/prep
306 (process-project project main project/merge-profiles [:provided]))
307 (process-project project main project/merge-profiles
308 (project/pom-scope-profiles project :provided)))
307309 (let [jar-file (get-jar-filename* project nil)]
308310 (write-jar project jar-file (filespecs project))
309311 (main/info "Created" (str jar-file))
33 (:require [leiningen.core.main :as main]
44 [leiningen.core.project :as project]
55 [clojure.java.io :as io]
6 [clojure.set :as set]
67 [clojure.string :as s]
78 [clojure.java.shell :as sh]
89 [clojure.data.xml :as xml]))
316317
317318 (defmethod xml-tags ::project
318319 ([_ project]
319 (let [reprofile #(relativize (project/merge-profiles project %))
320 default-kws (->> (-> project meta :profiles :default)
321 distinct
322 (remove #{:user :system}))
323 test-profile-kws (conj (vec default-kws) :test)
324 test-project (reprofile test-profile-kws)
325 profiles (merge @project/default-profiles (:profiles project)
326 (project/project-profiles project))
327 raw-deps (set (map dep-key (:dependencies project)))
328 deps (concat (:dependencies project)
329 (for [dep (:dependencies (:provided profiles))]
330 (make-scope "provided" dep))
331 (for [profile (concat
332 [:dev :test :base]
333 (remove #{:provided :dev :test :base}
334 test-profile-kws))
335 dep (:dependencies (profile profiles))
336 :when (not (and (= profile :base)
337 (raw-deps (dep-key dep))))]
338 (make-scope "test" dep)))]
320 (let [original-project (-> project meta ::original-project)
321 profile-kws (concat
322 (set/difference
323 (set (project/non-leaky-profiles original-project))
324 (set (project/pom-scope-profiles
325 original-project :provided))
326 (set (project/pom-scope-profiles
327 original-project :test))))
328 test-project (-> original-project
329 (project/unmerge-profiles profile-kws)
330 (project/merge-profiles [:test])
331 relativize)
332 deps (:dependencies test-project)]
339333 (list
340334 [:project {:xsi:schemaLocation
341335 (str "http://maven.apache.org/POM/4.0.0"
376370 (defn make-pom
377371 ([project] (make-pom project false))
378372 ([project disclaimer?]
379 (let [project (project/unmerge-profiles project [:default])]
373 (let [profile-kws (project/non-leaky-profiles project)
374 project (-> project
375 (project/unmerge-profiles profile-kws)
376 (vary-meta assoc ::original-project project))]
380377 (check-for-snapshot-deps project)
381378 (str
382379 (xml/indent-str
2626 (def sample-failing-project (read-test-project "sample-failing"))
2727
2828 (def sample-no-aot-project (read-test-project "sample-no-aot"))
29
30 (def sample-profile-meta-project (read-test-project "sample-profile-meta"))
2931
3032 (def tricky-name-project (read-test-project "tricky-name"))
3133
22 [clojure.java.io :only [file delete-file]]
33 [leiningen.pom :only [make-pom pom]]
44 [leiningen.core.user :as user]
5 [leiningen.test.helper :only [sample-project]
5 [leiningen.test.helper
6 :only [sample-project sample-profile-meta-project]
67 :as lthelper])
78 (:require [clojure.data.xml :as xml]
89 [leiningen.core.project :as project]
3132 (def first-in (comp first deep-content))
3233
3334 (defn with-profile [project name profile]
34 (-> project
35 (vary-meta update-in [:without-profiles :profiles]
36 assoc name profile)
37 (vary-meta update-in [:profiles]
38 assoc name profile)))
39
40 (defn with-profile-merged [project profile]
41 (project/merge-profiles (with-profile project :testy profile) [:testy]))
35 (let [profile (#'project/apply-profile-meta
36 (project/default-profile-metadata name)
37 profile)]
38 (-> project
39 (vary-meta update-in [:without-profiles :profiles]
40 assoc name profile)
41 (vary-meta update-in [:profiles]
42 assoc name profile))))
43
44 (defn with-profile-merged
45 ([project profile]
46 (with-profile-merged project :testy profile))
47 ([project name profile]
48 (project/merge-profiles (with-profile project name profile) [name])))
4249
4350 (deftest test-pom-default-values
4451 (let [xml (xml/parse-str (make-pom sample-project))]
109116
110117 (deftest test-dependencies-are-test-scoped
111118 (let [xml (xml/parse-str
112 (make-pom (with-profile
113 sample-project
114 :test
115 {:dependencies '[[peridot "0.0.5"]]})))]
116 (is (= ["org.clojure" "rome" "ring" "peridot"
117 "org.clojure" "clojure-complete"]
118 (map #(first-in % [:dependency :groupId])
119 (deep-content xml [:project :dependencies]))))
120 (is (= ["clojure" "rome" "ring" "peridot" "tools.nrepl" "clojure-complete"]
121 (map #(first-in % [:dependency :artifactId])
122 (deep-content xml [:project :dependencies]))))
123 (is (= ["1.3.0" "0.9" "1.0.0" "0.0.5" "0.2.5" "0.2.3"]
119 (make-pom (with-profile-merged
120 sample-project
121 :test {:dependencies '[[peridot "0.0.5"]]})))]
122 (is (= ["org.clojure" "rome" "ring"
123 "org.clojure" "clojure-complete" "peridot"]
124 (map #(first-in % [:dependency :groupId])
125 (deep-content xml [:project :dependencies]))))
126 (is (= ["clojure" "rome" "ring" "tools.nrepl" "clojure-complete" "peridot"]
127 (map #(first-in % [:dependency :artifactId])
128 (deep-content xml [:project :dependencies]))))
129 (is (= ["1.3.0" "0.9" "1.0.0" "0.2.5" "0.2.3" "0.0.5"]
124130 (map #(first-in % [:dependency :version])
125131 (deep-content xml [:project :dependencies]))))
126132 (is (= [nil nil nil "test" "test" "test"]
129135
130136 (deftest dev-dependencies-are-test-scoped
131137 (let [xml (xml/parse-str
132 (make-pom (with-profile
138 (make-pom (with-profile-merged
133139 sample-project
134140 :dev
135141 {:dependencies '[[peridot "0.0.5"]]})))]
136 (is (= ["org.clojure" "rome" "ring" "peridot"
137 "org.clojure" "clojure-complete"]
138 (map #(first-in % [:dependency :groupId])
139 (deep-content xml [:project :dependencies]))))
140 (is (= ["clojure" "rome" "ring" "peridot" "tools.nrepl" "clojure-complete"]
141 (map #(first-in % [:dependency :artifactId])
142 (deep-content xml [:project :dependencies]))))
143 (is (= ["1.3.0" "0.9" "1.0.0" "0.0.5" "0.2.5" "0.2.3"]
142 (is (= ["org.clojure" "rome" "ring"
143 "org.clojure" "clojure-complete" "peridot"]
144 (map #(first-in % [:dependency :groupId])
145 (deep-content xml [:project :dependencies]))))
146 (is (= ["clojure" "rome" "ring" "tools.nrepl" "clojure-complete" "peridot"]
147 (map #(first-in % [:dependency :artifactId])
148 (deep-content xml [:project :dependencies]))))
149 (is (= ["1.3.0" "0.9" "1.0.0" "0.2.5" "0.2.3" "0.0.5"]
144150 (map #(first-in % [:dependency :version])
145151 (deep-content xml [:project :dependencies]))))
146152 (is (= [nil nil nil "test" "test" "test"]
149155
150156 (deftest provided-dependencies-are-provided-scoped
151157 (let [xml (xml/parse-str
152 (make-pom (with-profile
158 (make-pom (with-profile-merged
153159 sample-project
154160 :provided
155161 {:dependencies '[[peridot "0.0.5"]]})))]
156 (is (= ["org.clojure" "rome" "ring" "peridot"
157 "org.clojure" "clojure-complete"]
158 (map #(first-in % [:dependency :groupId])
159 (deep-content xml [:project :dependencies]))))
160 (is (= ["clojure" "rome" "ring" "peridot" "tools.nrepl" "clojure-complete"]
161 (map #(first-in % [:dependency :artifactId])
162 (deep-content xml [:project :dependencies]))))
163 (is (= ["1.3.0" "0.9" "1.0.0" "0.0.5" "0.2.5" "0.2.3"]
164 (map #(first-in % [:dependency :version])
165 (deep-content xml [:project :dependencies]))))
166 (is (= [nil nil nil "provided" "test" "test"]
162 (is (= ["org.clojure" "rome" "ring"
163 "org.clojure" "clojure-complete" "peridot"]
164 (map #(first-in % [:dependency :groupId])
165 (deep-content xml [:project :dependencies]))))
166 (is (= ["clojure" "rome" "ring" "tools.nrepl" "clojure-complete" "peridot"]
167 (map #(first-in % [:dependency :artifactId])
168 (deep-content xml [:project :dependencies]))))
169 (is (= ["1.3.0" "0.9" "1.0.0" "0.2.5" "0.2.3" "0.0.5"]
170 (map #(first-in % [:dependency :version])
171 (deep-content xml [:project :dependencies]))))
172 (is (= [nil nil nil "test" "test" "provided"]
167173 (map #(first-in % [:dependency :scope])
168174 (deep-content xml [:project :dependencies]))))))
169175
171177 (let [xml (xml/parse-str
172178 (make-pom (with-profile-merged
173179 sample-project
174 {:dependencies '[[peridot "0.0.5"
175 :scope "provided"
176 :optional true
177 :classifier "sources"
178 :extension "pom"
179 :exclusions
180 [[ring-mock
181 :classifier "cla"
182 :extension "dom"]]]]})))]
183 (is (= ["org.clojure" "rome" "ring" "peridot"
184 "org.clojure" "clojure-complete"]
185 (map #(first-in % [:dependency :groupId])
186 (deep-content xml [:project :dependencies]))))
187 (is (= ["clojure" "rome" "ring" "peridot"
188 "tools.nrepl" "clojure-complete"]
189 (map #(first-in % [:dependency :artifactId])
190 (deep-content xml [:project :dependencies]))))
191 (is (= ["1.3.0" "0.9" "1.0.0" "0.0.5" "0.2.5" "0.2.3"]
192 (map #(first-in % [:dependency :version])
193 (deep-content xml [:project :dependencies]))))
194 (is (= [nil nil nil "provided" "test" "test"]
195 (map #(first-in % [:dependency :scope])
196 (deep-content xml [:project :dependencies]))))
197 (is (= [nil nil nil "true" nil nil]
180 ^:leaky {:dependencies '[[peridot "0.0.5"
181 :scope "provided"
182 :optional true
183 :classifier "sources"
184 :extension "pom"
185 :exclusions
186 [[ring-mock
187 :classifier "cla"
188 :extension "dom"]]]]})))]
189 (is (= ["org.clojure" "rome" "ring"
190 "org.clojure" "clojure-complete" "peridot"]
191 (map #(first-in % [:dependency :groupId])
192 (deep-content xml [:project :dependencies]))))
193 (is (= ["clojure" "rome" "ring"
194 "tools.nrepl" "clojure-complete" "peridot"]
195 (map #(first-in % [:dependency :artifactId])
196 (deep-content xml [:project :dependencies]))))
197 (is (= ["1.3.0" "0.9" "1.0.0" "0.2.5" "0.2.3" "0.0.5"]
198 (map #(first-in % [:dependency :version])
199 (deep-content xml [:project :dependencies]))))
200 (is (= [nil nil nil "test" "test" "provided"]
201 (map #(first-in % [:dependency :scope])
202 (deep-content xml [:project :dependencies]))))
203 (is (= [nil nil nil nil nil "true"]
198204 (map #(first-in % [:dependency :optional])
199205 (deep-content xml [:project :dependencies]))))
200 (is (= [nil nil nil "sources" nil nil]
206 (is (= [nil nil nil nil nil "sources"]
201207 (map #(first-in % [:dependency :classifier])
202208 (deep-content xml [:project :dependencies]))))
203 (is (= [nil nil nil "pom" nil nil]
209 (is (= [nil nil nil nil nil "pom"]
204210 (map #(first-in % [:dependency :type])
205211 (deep-content xml [:project :dependencies]))))
206 (is (= [nil nil nil "ring-mock" "clojure" "clojure"]
212 (is (= [nil nil nil "clojure" "clojure" "ring-mock"]
207213 (map #(first-in % [:dependency :exclusions :exclusion :artifactId])
208214 (deep-content xml [:project :dependencies]))))
209 (is (= [nil nil nil "ring-mock" "org.clojure" "org.clojure"]
215 (is (= [nil nil nil "org.clojure" "org.clojure" "ring-mock"]
210216 (map #(first-in % [:dependency :exclusions :exclusion :groupId])
211217 (deep-content xml [:project :dependencies]))))
212 (is (= [nil nil nil "cla" nil nil]
218 (is (= [nil nil nil nil nil "cla"]
213219 (map #(first-in % [:dependency :exclusions :exclusion :classifier])
214220 (deep-content xml [:project :dependencies]))))
215 (is (= [nil nil nil "dom" nil nil]
221 (is (= [nil nil nil nil nil "dom"]
216222 (map #(first-in % [:dependency :exclusions :exclusion :type])
217223 (deep-content xml [:project :dependencies])))))
218224 (let [xml (xml/parse-str
219225 (make-pom (with-profile-merged
220226 sample-project
221 {:dependencies '[[peridot "0.0.5"
222 :scope "provided"
223 :exclusions
224 [ring-mock]]]})))]
225 (is (= ["org.clojure" "rome" "ring" "peridot"
226 "org.clojure" "clojure-complete"]
227 (map #(first-in % [:dependency :groupId])
228 (deep-content xml [:project :dependencies]))))
229 (is (= ["clojure" "rome" "ring" "peridot" "tools.nrepl" "clojure-complete"]
230 (map #(first-in % [:dependency :artifactId])
231 (deep-content xml [:project :dependencies]))))
232 (is (= ["1.3.0" "0.9" "1.0.0" "0.0.5" "0.2.5" "0.2.3"]
233 (map #(first-in % [:dependency :version])
234 (deep-content xml [:project :dependencies]))))
235 (is (= [nil nil nil "provided" "test" "test"]
236 (map #(first-in % [:dependency :scope])
237 (deep-content xml [:project :dependencies]))))
238 (is (= [nil nil nil "ring-mock" "clojure" "clojure"]
227 ^:leaky {:dependencies '[[peridot "0.0.5"
228 :scope "provided"
229 :exclusions
230 [ring-mock]]]})))]
231 (is (= ["org.clojure" "rome" "ring"
232 "org.clojure" "clojure-complete" "peridot"]
233 (map #(first-in % [:dependency :groupId])
234 (deep-content xml [:project :dependencies]))))
235 (is (= ["clojure" "rome" "ring" "tools.nrepl" "clojure-complete" "peridot"]
236 (map #(first-in % [:dependency :artifactId])
237 (deep-content xml [:project :dependencies]))))
238 (is (= ["1.3.0" "0.9" "1.0.0" "0.2.5" "0.2.3" "0.0.5"]
239 (map #(first-in % [:dependency :version])
240 (deep-content xml [:project :dependencies]))))
241 (is (= [nil nil nil "test" "test" "provided"]
242 (map #(first-in % [:dependency :scope])
243 (deep-content xml [:project :dependencies]))))
244 (is (= [nil nil nil "clojure" "clojure" "ring-mock"]
239245 (map #(first-in % [:dependency :exclusions :exclusion :artifactId])
240246 (deep-content xml [:project :dependencies]))))
241247 (is (= [nil nil nil nil nil nil]
247253
248254 (deftest dependencies-are-required-when-overlapped-by-builtin-profiles
249255 (let [xml (xml/parse-str
250 (make-pom (with-profile sample-project
256 (make-pom (with-profile-merged
257 sample-project
251258 :dev {:dependencies '[[rome "0.8"]]})))]
252 (is (= ["org.clojure" "rome" "ring" "rome" "org.clojure" "clojure-complete"]
253 (map #(first-in % [:dependency :groupId])
254 (deep-content xml [:project :dependencies]))))
255 (is (= ["clojure" "rome" "ring" "rome" "tools.nrepl" "clojure-complete"]
256 (map #(first-in % [:dependency :artifactId])
257 (deep-content xml [:project :dependencies]))))
258 (is (= ["1.3.0" "0.9" "1.0.0" "0.8" "0.2.5" "0.2.3"]
259 (map #(first-in % [:dependency :version])
260 (deep-content xml [:project :dependencies]))))
261 (is (= [nil nil nil "test" "test" "test"]
259 (is (= ["org.clojure" "rome" "ring" "org.clojure" "clojure-complete"]
260 (map #(first-in % [:dependency :groupId])
261 (deep-content xml [:project :dependencies]))))
262 (is (= ["clojure" "rome" "ring" "tools.nrepl" "clojure-complete"]
263 (map #(first-in % [:dependency :artifactId])
264 (deep-content xml [:project :dependencies]))))
265 (is (= ["1.3.0" "0.8" "1.0.0" "0.2.5" "0.2.3"]
266 (map #(first-in % [:dependency :version])
267 (deep-content xml [:project :dependencies]))))
268 (is (= [nil "test" nil "test" "test"]
262269 (map #(first-in % [:dependency :scope])
263270 (deep-content xml [:project :dependencies]))))))
264271
268275 (is (= "stuff"
269276 (-> (make-pom (with-profile-merged
270277 sample-project
271 {:classifier "stuff"}))
278 ^:leaky {:classifier "stuff"}))
272279 xml/parse-str
273280 (first-in [:project :classifier])))))
274281
275282 (deftest test-pom-adds-java-source-paths
276283 (is (= (vec (map lthelper/fix-path-delimiters ["java/src" "java/another"]))
277284 (-> (make-pom (with-profile-merged sample-project
285 ^:leaky
278286 {:java-source-paths ["java/src" "java/another"]}))
279287 xml/parse-str
280288 (deep-content [:project :build :plugins :plugin :executions
284292 (deftest test-pom-handles-global-exclusions
285293 (is (= [["clojure"] ["clojure"] ["clojure"] ["clojure"] ["clojure"]]
286294 (-> (make-pom (with-profile-merged sample-project
287 {:exclusions '[org.clojure/clojure]}))
295 ^:leaky {:exclusions '[org.clojure/clojure]}))
288296 xml/parse-str
289297 (deep-content [:project :dependencies])
290298 ((partial map #(deep-content % [:dependency :exclusions])))
312320 [artifact (first-in dep [:dependency :classifier])])))))
313321
314322 (deftest test-override-base-profile
315 (let [p (make-pom (with-profile-merged sample-project
316 {:dependencies [['org.clojure/tools.nrepl "0.2.2"]]}))
323 (testing "leaky explicit profile"
324 (let [p (make-pom (with-profile-merged sample-project
325 ^:leaky
326 {:dependencies [['org.clojure/tools.nrepl "0.2.2"]]}))
327 deps (deep-content (xml/parse-str p) [:project :dependencies])
328 nrepls (filter #(re-find #"nrepl" (pr-str %)) deps)
329 versions (map #(deep-content % [:dependency :version]) nrepls)]
330 (is (= [["0.2.2"]] versions))))
331 (testing "pom-scope"
332 (let [p (make-pom (with-profile-merged sample-project
333 ^{:pom-scope :test}
334 {:dependencies [['org.clojure/tools.nrepl "0.2.2"]]}))
335 deps (deep-content (xml/parse-str p) [:project :dependencies])
336 nrepls (filter #(re-find #"nrepl" (pr-str %)) deps)
337 versions (map #(deep-content % [:dependency :version]) nrepls)]
338 (is (= [["0.2.2"]] versions)))))
339
340 (deftest test-leaky-profile
341 (let [p (make-pom sample-profile-meta-project)
317342 deps (deep-content (xml/parse-str p) [:project :dependencies])
318 nrepls (filter #(re-find #"nrepl" (pr-str %)) deps)
319 versions (map #(deep-content % [:dependency :version]) nrepls)]
320 (is (= [["0.2.2"]] versions))))
343 t-m (filter #(re-find #"tools.macro" (pr-str %)) deps)
344 j-c (filter #(re-find #"java.classpath" (pr-str %)) deps)
345 t-n (filter #(re-find #"tools.namespace" (pr-str %)) deps)]
346 (is (= [["0.1.2"]] (map #(deep-content % [:dependency :version]) t-m)))
347 (is (= [["0.2.2"]] (map #(deep-content % [:dependency :version]) j-c)))
348 (is (= [["0.2.6"]] (map #(deep-content % [:dependency :version]) t-n)))
349 (is (= [nil] (map #(deep-content % [:dependency :scope]) t-m)))
350 (is (= [["test"]] (map #(deep-content % [:dependency :scope]) j-c)))
351 (is (= [["provided"]] (map #(deep-content % [:dependency :scope]) t-n)))))
0 ;; This project is used for leiningen's test suite, so don't change
1 ;; any of these values without updating the relevant tests. If you
2 ;; just want a basic project to work from, generate a new one with
3 ;; "lein new".
4
5 (defproject nomnomnom "0.5.0-SNAPSHOT"
6 :dependencies []
7 :profiles {:default [:core-default :my-leaky :my-provided :my-test]
8 :my-leaky ^:leaky {:dependencies
9 [[org.clojure/tools.macro "0.1.2"]]}
10 :my-test
11 ^{:pom-scope :test} {:dependencies
12 [[org.clojure/java.classpath "0.2.2"]]}
13 :my-provided
14 ^{:pom-scope :provided} {:dependencies
15 [[org.clojure/tools.namespace "0.2.6"]]}})