Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
107 lines (92 sloc) 2.97 KB
(ns lucid.package.pom
(:require [clojure.string :as string]
[hiccup.core :as html]
[file :as fs]
[project :as project]]))
(str ""
" "
(defn pom-properties
"creates a file
(pom-properties (project/project))"
{:added "1.2"}
(str "# lucid.distribute\n"
"# " (java.util.Date.) "\n"
"version=" (:version project) "\n"
"groupId=" (:group project) "\n"
"artifactId=" (:artifact project)))
(defn coordinate->dependency
"creates a hiccup dependency entry
(coordinate->dependency '[im.chit/hara \"0.1.1\"])
=> [:dependency
[:groupId \"im.chit\"]
[:artifactId \"hara\"]
[:version \"0.1.1\"]]"
{:added "1.2"}
[[full version]]
(let [group (or (namespace full)
(str full))
artifact (name full)]
[:groupId group]
[:artifactId artifact]
[:version version]]))
(defn pom-xml
"creates a file
(pom-xml (project/project))"
{:added "1.2"}
(str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
[:project HEADER
[:modelVersion "4.0.0"]
[:packaging "jar"]
[:groupId (:group project)]
[:artifactId (:artifact project)]
[:version (:version project)]
[:name (str (:name project))]
[:description (:description project)]
[:url (:url project)]
[:name (-> project :license :name)]
[:url (-> project :license :url)]]]
[:id "central"]
[:url ""]
[:snapshots [:enabled "false"]]
[:releases [:enabled "true"]]]
[:id "clojars"]
[:url ""]
[:snapshots [:enabled "true"]]
[:releases [:enabled "true"]]]]
(apply vector :dependencies
(map coordinate->dependency (:dependencies project)))])))
(defn generate-pom
"generates all the pom information for the project
(pom-xml (project/project))"
{:added "1.2"}
(let [root (:root project)
output (str "target/classes/META-INF/maven/"
(:group project)
(:artifact project))
pom-path (str root "/target/" (:artifact project) "-" (:version project) ".pom.xml")
xml (pom-xml project)]
(fs/create-directory (fs/path root output))
(spit (str (fs/path root output "pom.xml")) xml)
(spit (str (fs/path root output "")) (pom-properties project))
(spit pom-path xml)