Skip to content

Commit e7898a9

Browse files
arichiardimartinklepsch
authored andcommitted
Handle pom <parent> tag
This patch adds support for the `<parent>` tag in `boot.pom` for both writing and reading `pom.xml` files.
1 parent 9b21dd9 commit e7898a9

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

boot/core/src/boot/task/built_in.clj

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -541,16 +541,17 @@
541541
classifier to your pom.xml, which translates to adding :classifier to this
542542
task."
543543

544-
[p project SYM sym "The project id (eg. foo/bar)."
545-
v version VER str "The project version."
546-
d description DESC str "The project description."
547-
c classifier STR str "The project classifier."
548-
P packaging STR str "The project packaging type, i.e. war, pom"
549-
u url URL str "The project homepage url."
550-
s scm KEY=VAL {kw str} "The project scm map (KEY is one of url, tag, connection, developerConnection)."
551-
l license NAME:URL {str str} "The map {name url} of project licenses."
552-
o developers NAME:EMAIL {str str} "The map {name email} of project developers."
553-
D dependencies SYM:VER [[sym str]] "The project dependencies vector (overrides boot env dependencies)."]
544+
[p project SYM sym "The project id (eg. foo/bar)."
545+
v version VER str "The project version."
546+
d description DESC str "The project description."
547+
c classifier STR str "The project classifier."
548+
P packaging STR str "The project packaging type, i.e. war, pom"
549+
u url URL str "The project homepage url."
550+
s scm KEY=VAL {kw str} "The project scm map (KEY is one of url, tag, connection, developerConnection)."
551+
l license NAME:URL {str str} "The map {name url} of project licenses."
552+
o developers NAME:EMAIL {str str} "The map {name email} of project developers."
553+
D dependencies SYM:VER [[sym str]] "The project dependencies vector (overrides boot env dependencies)."
554+
a parent SYM:VER=PATH [sym str str] "The project dependency vector of the parent project, path included."]
554555

555556
(let [tgt (core/tmp-dir!)
556557
tag (or (:tag scm) (util/guard (git/last-commit)))
@@ -561,7 +562,8 @@
561562
:dependencies deps
562563
:developers developers
563564
:classifier classifier
564-
:packaging (or packaging "jar"))]
565+
:packaging (or packaging "jar")
566+
:parent parent)]
565567
(when-not (and project version)
566568
(throw (Exception. "need project and version to create pom.xml")))
567569
(let [[project version] (pod/canonical-coord [project version])

boot/worker/src/boot/pom.clj

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,33 @@
2020
artifactId connection description dependencies dependency exclusion
2121
exclusions developerConnection enabled groupId id license licenses
2222
modelVersion name email project scope tag url scm version comments
23-
developer developers packaging classifier)
23+
developer developers packaging classifier parent relativePath)
2424

2525
;;; private ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2626

27+
(defn pom-parent-parse [z]
28+
(let [gid (util/guard (xml1-> z :groupId text))
29+
aid (util/guard (xml1-> z :artifactId text))
30+
v (util/guard (xml1-> z :version text))
31+
dep (when aid
32+
(if (= gid aid)
33+
[(symbol aid) v]
34+
[(symbol gid aid) v]))
35+
rp (util/guard (xml1-> z :relativePath text))]
36+
{:dependency dep
37+
:relative-path rp}))
38+
2739
(defn pom-xml-parse-string [xml-str]
2840
(let [z (-> xml-str .getBytes ByteArrayInputStream. parse xml-zip)
2941
gid (util/guard (xml1-> z :groupId text))
30-
aid (util/guard (xml1-> z :artifactId text))]
42+
aid (util/guard (xml1-> z :artifactId text))
43+
parent-z (util/guard (xml1-> z :parent))]
3144
{:project (util/guard (if (= gid aid) (symbol aid) (symbol gid aid)))
3245
:version (util/guard (xml1-> z :version text))
3346
:description (util/guard (xml1-> z :description text))
3447
:classifier (util/guard (xml1-> z :classifier text))
3548
:url (util/guard (xml1-> z :url text))
49+
:parent (when parent-z (pom-parent-parse parent-z))
3650
:scm {:url (util/guard (xml1-> z :scm :url text))
3751
:tag (util/guard (xml1-> z :scm :tag text))}}))
3852

@@ -55,6 +69,7 @@
5569
u :url
5670
c :classifier
5771
deps :dependencies
72+
prnt :parent
5873
:as env}]
5974
(let [[g a] (util/extract-ids p)
6075
ls (map (fn [[name url]] {:name name :url url}) l)]
@@ -63,6 +78,15 @@
6378
:xmlns:xsi "http://www.w3.org/2001/XMLSchema-instance"
6479
:xsi:schemaLocation "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
6580
(modelVersion "4.0.0")
81+
(when prnt
82+
(let [[p v & {rp :relative-path}] prnt
83+
[g a] (util/extract-ids p)]
84+
(parent
85+
(groupId g)
86+
(artifactId a)
87+
(version v)
88+
(when rp
89+
(relativePath rp)))))
6690
(groupId g)
6791
(artifactId a)
6892
(version v)

0 commit comments

Comments
 (0)