Skip to content

Commit

Permalink
Expand profiles before calculating which to remove in jar task.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Aug 9, 2022
1 parent 1e6cca9 commit 91e9e25
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions leiningen-core/src/leiningen/core/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,10 @@
(let [{:keys [included-profiles excluded-profiles]} (meta project)
profiles (expand-profiles project profiles)]
(set-profiles project
;; we need un-expanded profiles here because if :dev was
;; a composite profile that included :foo, we need to start
;; from :dev in order to ensure :foo's dependencies have
;; test scope in the pom.
(remove (set profiles) included-profiles)
(concat excluded-profiles profiles))))

Expand Down
3 changes: 2 additions & 1 deletion src/leiningen/jar.clj
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ With an argument, the jar will be built with an alternate main."
default-profiles (set (project/expand-profile project :default))
provided-profiles (remove
(set/difference default-profiles scoped-profiles)
(-> project meta :included-profiles))
(->> project meta :included-profiles
(project/expand-profiles project)))
project (preprocess-project project main)]
(merge (main-jar project provided-profiles main)
(classifier-jars project provided-profiles)))))
Expand Down
5 changes: 4 additions & 1 deletion test/leiningen/test/jar.clj
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@

(deftest test-no-aot-jar-succeeds
(with-out-str
(is (jar helper/sample-no-aot-project))))
(let [project (helper/read-test-project "sample-no-aot")
jar (first (vals (jar project)))
entry-names (set (helper/walkzip jar #(.getName %)))]
(is (not (entry-names "dev.clj"))))))

(deftest test-classifier-jar-succeeds
(is (= 1 (count (:classifiers helper/with-classifiers-project)))
Expand Down
9 changes: 5 additions & 4 deletions test/leiningen/test/uberjar.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
data-readers-backwards-compatibility-project
provided-project
managed-deps-project
managed-deps-snapshot-project]])
managed-deps-snapshot-project] :as h])
(:import (java.io File FileOutputStream)
(java.util.zip ZipFile)))

(deftest test-uberjar
(with-out-str
(uberjar sample-no-aot-project))
(let [filename (str "test_projects/sample-no-aot/target/"
(let [project (h/read-test-project "sample-no-aot")
_ (with-out-str
(uberjar sample-no-aot-project))
filename (str "test_projects/sample-no-aot/target/"
"nomnomnom-0.5.0-SNAPSHOT-standalone.jar")
uberjar-file (File. filename)]
(is (= true (.exists uberjar-file)))
Expand Down

0 comments on commit 91e9e25

Please sign in to comment.