Skip to content

Commit 7cb4eb1

Browse files
authored
Merge pull request #219 from liquidz/dev
Next release
2 parents 2ca894e + 7f7aa9d commit 7cb4eb1

File tree

5 files changed

+84
-12
lines changed

5 files changed

+84
-12
lines changed

CHANGELOG.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
All notable changes to this project will be documented in this file. This change log follows the conventions of http://keepachangelog.com/[keepachangelog.com].
22

33
== Unreleased (dev)
4+
// {{{
5+
=== Changed
6+
* Bumped build.edn to 0.9.216.
7+
8+
=== Fixed
9+
* https://github.com/liquidz/antq/issues/217[#217]: Fixed pom.xml upgrader to work correctly when pom.xml contains `exclusions` tag.
10+
// }}}
411

512
== 2.4.1062 (2023-05-01)
613
// {{{

deps.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
:main-opts ["-m" "cloverage.coverage" "--ns-exclude-regex" "leiningen.antq"]}
4343

4444
:build
45-
{:deps {com.github.liquidz/build.edn {:mvn/version "0.9.203"}}
45+
{:deps {com.github.liquidz/build.edn {:mvn/version "0.9.216"}}
4646
:ns-default build}
4747

4848
;; -X

src/antq/upgrade/pom.clj

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,37 @@
2424
(defn- target-dependency?
2525
[loc group-id artifact-id]
2626
(let [{:keys [tag content]} (zip/node loc)]
27-
(if (and tag
28-
(= "groupId" (name tag))
29-
(= [group-id] content))
30-
(->> (zip/rights loc)
31-
(filter #(and (tag=? "artifactId")
32-
(= [artifact-id] (:content %))))
33-
(seq)
34-
(some?))
35-
false)))
27+
28+
(cond
29+
;; group-id
30+
(not (and tag
31+
(= "groupId" (name tag))
32+
(= [group-id] content)))
33+
false
34+
35+
;; artifact-id next to group-id
36+
(not (->> (zip/rights loc)
37+
(filter #(and (= "artifactId" (name (:tag %)))
38+
(= [artifact-id] (:content %))))
39+
(seq)
40+
(some?)))
41+
false
42+
43+
;; exlusion
44+
(-> loc
45+
(zip/up)
46+
(tag-name)
47+
(= "exclusion"))
48+
false
49+
50+
:else
51+
true)))
3652

3753
(defn- version-property-name
3854
[loc]
39-
(let [loc (find-version loc)
40-
{:keys [content]} (zip/node loc)]
55+
(let [{:keys [content]} (some-> loc
56+
(find-version)
57+
(zip/node))]
4158
(some->> (first content)
4259
(re-seq #"\$\{(.+?)\}")
4360
(first)

test/antq/upgrade/pom_test.clj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
:latest-version "9.0.0"
3333
:file (io/file (io/resource "dep/child_pom/child/pom.xml"))}))
3434

35+
(def ^:private dummy-java-with-exclusion-dep
36+
(r/map->Dependency {:project :pom
37+
:type :java
38+
:name "com.bar/bar"
39+
:latest-version "9.0.0"
40+
:file (io/file (io/resource "dep/test_pom_exclusions.xml"))}))
41+
3542
(t/deftest upgrade-dep-test
3643
(let [tmp-file (File/createTempFile "upgrade-dep-test" "xml")]
3744
(try
@@ -74,3 +81,18 @@
7481
(t/deftest upgrade-dep-with-child-pom-test
7582
(t/is (nil? (->> dummy-parent-child-java-dep
7683
(upgrade/upgrader)))))
84+
85+
(t/deftest upgrade-dep-with-exclusion-test
86+
(let [tmp-file (File/createTempFile "upgrade-dep-test" "xml")]
87+
(try
88+
(let [from-deps (->> dummy-java-with-exclusion-dep
89+
:file
90+
(dep.pom/extract-deps ""))
91+
_ (->> dummy-java-with-exclusion-dep
92+
(upgrade/upgrader)
93+
(spit tmp-file))
94+
to-deps (dep.pom/extract-deps "" tmp-file)]
95+
(t/is (= #{{:name "com.bar/bar" :version {:- "1.0.0" :+ "9.0.0"}}}
96+
(h/diff-deps from-deps to-deps))))
97+
(finally
98+
(.delete tmp-file)))))
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>foo</groupId>
5+
<artifactId>foo</artifactId>
6+
<version>0.1.0-SNAPSHOT</version>
7+
<name>foo</name>
8+
<dependencies>
9+
<dependency>
10+
<groupId>com.foo</groupId>
11+
<artifactId>foo</artifactId>
12+
<version>1.0.0</version>
13+
<exclusions>
14+
<exclusion>
15+
<groupId>com.bar</groupId>
16+
<artifactId>bar</artifactId>
17+
</exclusion>
18+
</exclusions>
19+
</dependency>
20+
<dependency>
21+
<groupId>com.bar</groupId>
22+
<artifactId>bar</artifactId>
23+
<version>1.0.0</version>
24+
</dependency>
25+
</dependencies>
26+
</project>

0 commit comments

Comments
 (0)