Skip to content

Commit

Permalink
Fix #220: don't use default HEAD tag in pom <scm>
Browse files Browse the repository at this point in the history
- The pom task now no longer explicitly adds HEAD as the scm tag in
  pom.xml if no tag is specified and no git commit can be automatically
  discovered. HEAD is already the Maven default so it wasn't necessary,
  and it confused other tasks that were looking at the pom.xml and
  comparing the scm info (see below).

- The pom task now correctly supports the <developerConnection> and
  <connection> elements as children of <scm>. Specify these in the :scm
  option map via :connection and :developerConnection. (This is probably
  only useful for creating pom.xml files for Maven to use, but it's in
  there, anyway.)

- The push task no longer throws an exception if the :ensure-tag option
  is specified but no scm info is available in the pom.xml. It now
  prints a warning to stderr instead.
  • Loading branch information
micha committed Jun 11, 2015
1 parent 76980e6 commit d878241
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
6 changes: 4 additions & 2 deletions boot/core/src/boot/task/built_in.clj
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@

(let [tgt (core/tmp-dir!)]
(core/with-pre-wrap fileset
(let [tag (or (:tag scm) (util/guard (git/last-commit)) "HEAD")
(let [tag (or (:tag scm) (util/guard (git/last-commit)))
scm (when scm (assoc scm :tag tag))
opts (assoc *opts* :scm scm :dependencies (:dependencies (core/get-env)))]
(core/empty-dir! tgt)
Expand Down Expand Up @@ -734,8 +734,10 @@
(format "not a release version (%s)" v))
(assert (or (not ensure-snapshot) snapshot?)
(format "not a snapshot version (%s)" v))
(assert (or (not ensure-tag) (= t ensure-tag))
(assert (or (not ensure-tag) (not t) (= t ensure-tag))
(format "scm tag in pom doesn't match (%s, %s)" t ensure-tag))
(when (and ensure-tag (not t))
(util/warn "The --ensure-tag option was specified but scm info is missing from pom.xml\n"))
(assert (or (not ensure-version) (= v ensure-version))
(format "jar version doesn't match project version (%s, %s)" v ensure-version))
(util/info "Deploying %s...\n" (.getName f))
Expand Down
3 changes: 0 additions & 3 deletions boot/worker/src/boot/jgit.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
[]
(with-repo (->> (jgit/git-log repo) first .getName)))

;;; FIXME: handle case where repo is not at ".", need to add ".." for each
;;; subdirectory level we are below the repo root, so this is broken

(defn ls-files
[& {:keys [ref untracked]}]
(with-repo
Expand Down
22 changes: 17 additions & 5 deletions boot/worker/src/boot/pom.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@
:scm {:url (util/guard (xml1-> z :scm :url text))
:tag (util/guard (xml1-> z :scm :tag text))}}))

(defn pom-xml [{p :project v :version d :description l :license
{su :url st :tag} :scm u :url deps :dependencies :as env}]
(defn pom-xml [{p :project
v :version
d :description
l :license
{su :url
st :tag
sc :connection
sd :developerConnection} :scm
u :url
deps :dependencies
:as env}]
(let [[g a] (util/extract-ids p)
ls (map (fn [[name url]] {:name name :url url}) l)]
(project
Expand All @@ -55,9 +64,12 @@
(url lu)
(name ln)
(comments lc))))
(scm
(url su)
(tag (or st "HEAD")))
(when (or su st sc sd)
(scm
(when sc (connection sc))
(when sd (developerConnection sd))
(when su (url su))
(when st (tag st))))
(dependencies
(for [[p v & {es :exclusions s :scope}] deps
:let [[g a] (util/extract-ids p)]]
Expand Down

1 comment on commit d878241

@agarman
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, great fix!

Please sign in to comment.