Permalink
Browse files

Merge pull request #4 from technomancy/master

Create new 0.2.0 version that works with Leiningen 2
  • Loading branch information...
2 parents 4db8d16 + 6e765d5 commit d8741a9c6999a6852ef032b2eb4b59588ae43969 @kumarshantanu committed Feb 23, 2012
Showing with 17 additions and 20 deletions.
  1. +1 −0 .gitignore
  2. +2 −2 project.clj
  3. +14 −16 src/leiningen/sub.clj
  4. +0 −2 test/leiningen/test_sub.clj
View
1 .gitignore
@@ -0,0 +1 @@
+target/
View
4 project.clj
@@ -1,4 +1,4 @@
-(defproject lein-sub "0.1.2"
+(defproject lein-sub "0.2.0"
:description "Leiningen Subprojects plugin"
:url "https://github.com/kumarshantanu/lein-sub"
- :dev-dependencies [[org.clojure/clojure "1.3.0"]])
+ :eval-in-leiningen true)
View
30 src/leiningen/sub.clj
@@ -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")))
View
2 test/leiningen/test_sub.clj
@@ -1,2 +0,0 @@
-(ns leiningen.test-sub
- (:use clojure.test))

0 comments on commit d8741a9

Please sign in to comment.