(ns clojars.maven
  (:require [clojure.java.io :as io])
  (:import org.apache.maven.model.io.xpp3.MavenXpp3Reader))

(defn model-to-map [model]
  {:name (.getArtifactId model)
   :group (.getGroupId model)
   :version (.getVersion model)
   :description (.getDescription model)
   :homepage (.getUrl model)
   :authors (vec (map #(.getName %) (.getContributors model)))
   ;; TODO: doesn't appear to be used anywhere?
   :dependencies (vec (mapcat (fn [d] [(symbol (.getGroupId d)
                                               (.getArtifactId d))
                                       (.getVersion d)])
                              (.getDependencies model)))})

(defn read-pom
  "Reads a pom file returning a maven Model object."
  [file]
  (with-open [reader (io/reader file)]
    (.read (MavenXpp3Reader.) reader)))


(def pom-to-map (comp model-to-map read-pom))
(ns clojars.maven
  (:require [clojure.java.io :as io])
  (:import org.apache.maven.model.io.xpp3.MavenXpp3Reader))

(defn model-to-map [model]
  {:name (.getArtifactId model)
   :group (.getGroupId model)
   :version (.getVersion model)
   :description (.getDescription model)
   :homepage (.getUrl model)
   :url (.getUrl model)
   :licenses (.getLicenses model)
   :scm (.getScm model)
   :authors (vec (map #(.getName %) (.getContributors model)))
   ;; TODO: doesn't appear to be used anywhere?
   :dependencies (vec (mapcat (fn [d] [(symbol (.getGroupId d)
                                               (.getArtifactId d))
                                       (.getVersion d)])
                              (.getDependencies model)))})

(defn read-pom
  "Reads a pom file returning a maven Model object."
  [file]
  (with-open [reader (io/reader file)]
    (.read (MavenXpp3Reader.) reader)))

(def pom-to-map (comp model-to-map read-pom))
Add a few more fields to pom-to-map.
Add a few more fields to pom-to-map.

clojars/clojars-web,technomancy/clojars-web,tobias/clojars-web,nberger/clojars-web,beppu/clojars-web,ato/clojars-web,ato/clojars-web,codonnell/clojars-web,dotemacs/clojars-web,tobias/clojars-web,xeqi/clojars-web,nberger/clojars-web,clojars/clojars-web,tobias/clojars-web,codonnell/clojars-web,leonid-shevtsov/clojars-web,clojars/clojars-web,dotemacs/clojars-web,technomancy/clojars-web,thiagofm/clojars-web,xeqi/clojars-web