-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marko Topolnik
committed
Mar 19, 2013
0 parents
commit 034913c
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/target | ||
/lib | ||
/classes | ||
/checkouts | ||
pom.xml | ||
pom.xml.asc | ||
*.jar | ||
*.class | ||
.lein-deps-sum | ||
.lein-failures | ||
.lein-plugins | ||
.lein-repl-history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(defproject com.ingemark/lein-with-checkout "0.1.0-SNAPSHOT" | ||
:description "Check out a revision from git and apply tasks on it" | ||
:url "https://github.com/Inge-mark/lein-with-checkout" | ||
:license {:name "Eclipse Public License" | ||
:url "http://www.eclipse.org/legal/epl-v10.html"} | ||
:eval-in :leiningen | ||
:lein-release {:deploy-via :clojars} | ||
|
||
:dependencies [[org.clojure/clojure "1.5.1"]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(ns leiningen.with-checkout | ||
(require [leiningen.core.main :as main] | ||
(clojure.java [shell :as sh] [io :as io]) | ||
[clojure.string :as s])) | ||
|
||
(set! *warn-on-reflection* true) | ||
|
||
(defn abort [fmt & args] (main/abort (apply format fmt args))) | ||
|
||
(defn sh! [& args] | ||
(apply println "$" args) | ||
(let [p (-> (ProcessBuilder. ^"[Ljava.lang.String;" (into-array args)) | ||
(.redirectErrorStream true) | ||
.start)] | ||
(io/copy (.getInputStream p) System/out) | ||
(let [res (.waitFor p)] | ||
(when-not (zero? res) (abort "Command failed with exit code %s: %s" res args)) | ||
res))) | ||
|
||
(defn with-checkout [project tag & args] | ||
(let [tag (if (= tag :latest) "`git tag | tail -1`" tag) | ||
checkout-dir "target/lein-with-checkout"] | ||
(sh! "mkdir" "-p" checkout-dir) | ||
(try | ||
(sh! "sh" "-c" (format "git archive %s | tar -xC %s" tag checkout-dir)) | ||
(sh! "sh" "-c" (format "cd %s ; lein %s" checkout-dir (s/join " " args))) | ||
(finally (sh! "rm" "-rf" checkout-dir))))) |