Permalink
Browse files

Rewrite to support Leiningen 2.

  • Loading branch information...
1 parent 45ef8cb commit 5da4589f0f1a02cd60ebcb11dd7944354db58784 @technomancy technomancy committed Feb 22, 2012
Showing with 14 additions and 18 deletions.
  1. +14 −16 src/leiningen/sub.clj
  2. +0 −2 test/leiningen/test_sub.clj
View
@@ -1,29 +1,27 @@
(ns leiningen.sub
- (:use [leiningen.core :only [apply-task exit read-project
- task-not-found]]))
+ (:require [leiningen.core.main :as main]
+ [leiningen.core.project :as project]))
-
-(defn run-sub-proj
+(defn apply-task-to-subproject
[sub-proj-dir task-name args]
(println "Reading project from" sub-proj-dir)
- (let [sub-project (read-project (str sub-proj-dir "/project.clj"))]
- (apply-task task-name sub-project args task-not-found)))
+ (let [sub-project (project/read (str sub-proj-dir "/project.clj"))]
+ (main/apply-task task-name sub-project args)))
+(defn run-subproject [task-name args total-result sub]
+ (if (zero? total-result)
+ (let [result (apply-task-to-subproject sub task-name args)]
+ (if (and (integer? result) (pos? result)) result 0))
+ total-result))
(defn sub
"Run task for all subprojects"
[project task-name & args]
- (if (empty? (:sub project))
+ (if-let [subprojects (:sub project)]
+ (reduce (partial run-subproject task-name args)
+ 0 (:sub project))
(println "No subprojects defined. Define with :sub key in project.clj, e.g.
:sub [\"modules/dep1\" \"modules/proj-common\"]
-Note: Each sub-project directory should have its own project.clj file")
- (when-let [code (reduce (fn [a b]
- (let [a (if (= 0 a) nil a)
- b (if (= 0 b) nil b)]
- (or a b)))
- (map #(let [r (run-sub-proj % task-name args)]
- (if (and (integer? r) (pos? r)) r 0))
- (:sub project)))]
- (exit code))))
+Note: Each sub-project directory should have its own project.clj file")))
@@ -1,2 +0,0 @@
-(ns leiningen.test-sub
- (:use clojure.test))

0 comments on commit 5da4589

Please sign in to comment.