Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternate repo root #872

Merged
merged 1 commit into from Nov 29, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions leiningen-core/project.clj
Expand Up @@ -11,6 +11,7 @@
[com.cemerick/pomegranate "0.0.13"
:exclusions [org.slf4j/slf4j-api]]]
:repositories [["classic" "https://clojars.org/repo/"]]
:scm {:dir ".."}
;; This is only used when releasing Leiningen. Can't put it in a
;; profile since it must be installed using lein1
;;:aot :all
Expand Down
8 changes: 7 additions & 1 deletion sample.project.clj
Expand Up @@ -265,7 +265,13 @@
;; Include <scm> tag in generated pom.xml file. All key/value pairs
;; appear exactly as configured. If absent, Leiningen will try to
;; use information from a .git directory.
:scm {:name "git" :tag "098afd745bcd" :url "http://127.0.0.1/git/my-project"}
:scm {:name "git"
:tag "098afd745bcd"
:url "http://127.0.0.1/git/my-project"
;; Allows you to use a repository in a different directory than the
;; project's root, for instance, if you had multiple projects in a
;; single git repository.
:dir ".."}

;; include arbitrary xml in generated pom.xml file
:pom-addition [:developers [:developer [:name "My Name"]]])
Expand Down
17 changes: 9 additions & 8 deletions src/leiningen/pom.clj
Expand Up @@ -20,12 +20,13 @@

;; git scm

(defn- resolve-git-dir [git-dir]
(let [git-dir-file (io/file git-dir)]
(cond
(.isDirectory git-dir-file) git-dir-file
(.isFile git-dir-file) (io/file (second (re-find #"gitdir: (\S+)" (slurp (str git-dir-file)))))
:else git-dir)))
(defn- resolve-git-dir [project]
(let [alternate-git-root (io/file (get-in project [:scm :dir]))
git-dir-file (io/file (or alternate-git-root (:root project)) ".git")]
(if
(.isFile git-dir-file)
(io/file (second (re-find #"gitdir: (\S+)" (slurp (str git-dir-file)))))
git-dir-file)))

(defn- read-git-ref
"Reads the commit SHA1 for a git ref path."
Expand Down Expand Up @@ -110,7 +111,7 @@
Retains backwards compatibility without an :scm map."
(if
(= "auto" scm)
(make-git-scm (resolve-git-dir (io/file (:root project) ".git")))
(make-git-scm (resolve-git-dir project))
(xml-tags :scm (xmlify (select-keys (:scm project)
[:url :connection
:tag :developerConnection])))))
Expand Down Expand Up @@ -337,7 +338,7 @@
(.setProperty "version" (:version project))
(.setProperty "groupId" (:group project))
(.setProperty "artifactId" (:name project)))
git-head (resolve-git-dir (io/file (:root project) ".git"))]
git-head (resolve-git-dir project)]
(when (.exists git-head)
(.setProperty properties "revision" (read-git-head git-head)))
(.store properties baos "Leiningen"))
Expand Down