Skip to content

Commit

Permalink
Fixing issues with pom generation when entries don't exist
Browse files Browse the repository at this point in the history
Conditionally checking for :distributionManagement and :build.
Catering for missing groupId when creating artifact-sym.
removing blank or empty values from project map.
Including version in :parent info
  • Loading branch information
thickey committed Mar 14, 2012
1 parent 87cd1e7 commit 244afab
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/leiningen/nevam/pom2proj.clj
Expand Up @@ -26,7 +26,7 @@

(defn- artifact-sym
[{:keys [groupId artifactId]}]
(symbol (if (= groupId artifactId)
(symbol (if (or (not groupId) (= groupId artifactId))
artifactId
(str groupId "/" artifactId))))

Expand Down Expand Up @@ -64,24 +64,28 @@

(defn- deploy-repositories
[pom-zip]
(let [dist (zx/xml1-> pom-zip :distributionManagement)]
(when-let [dist (zx/xml1-> pom-zip :distributionManagement)]
{:releases (zx/xml1-> dist :repository :url zx/text)
:snapshots (zx/xml1-> dist :snapshotRepository :url zx/text)}))

(defn- build
[pom-zip]
(let [bld (zx/xml1-> pom-zip :build)]
(when-let [bld (zx/xml1-> pom-zip :build)]
{:source-paths [(zx/xml1-> bld :sourceDirectory zx/text)]
:test-paths [(zx/xml1-> bld :testSourceDirectory zx/text)]
:resource-paths (into [] (zx/xml-> bld :resources :resource :directory zx/text))}))

(defn- lein-project-info
[xz]
(assoc (merge (project xz) (build xz))
:dependencies (dependencies xz)
:repositories (repositories xz)
:deploy-repositories (deploy-repositories xz)
:parent (parent xz)))
(let [attrs {:dependencies (dependencies xz)
:repositories (repositories xz)
:deploy-repositories (deploy-repositories xz)
:parent (parent xz)}
attrs (filter (fn [[k v]]
(if (coll? v) (not-empty v) v))
attrs)]
(into (merge (project xz) (build xz))
attrs)))

(defn- format-dependencies
[deps]
Expand All @@ -97,7 +101,7 @@
(defn- format-parent
[parent]
(let [rel (:relativePath parent)
p [(artifact-sym parent)]]
p [(artifact-sym parent) (:version parent)]]
(if rel
(conj p :relative-path rel)
p)))
Expand All @@ -108,7 +112,9 @@
info (assoc info
:dependencies (format-dependencies dependencies)
:parent (format-parent parent))
info (into {} (filter (fn [[k v]] v) info))
info (into {} (filter (fn [[k v]]
(if (coll? v) (not-empty v) v))
info))
pf `(~'defproject ~(artifact-sym project) ~(:version project)
~@(mapcat (fn [[k v]] [k v]) info))]
pf))
Expand Down

0 comments on commit 244afab

Please sign in to comment.