Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Got rid of contrib dependencies.

  • Loading branch information...
commit ca6856f59c7872a4df0e33a7cbaed264d5f81ec3 1 parent f0546c6
Roman Scherer authored
2  .gitignore
@@ -3,3 +3,5 @@ lib
3 3 *~
4 4 pom.xml
5 5 *.jar
  6 +/.lein-deps-sum
  7 +/.lein-failures
12 project.clj
... ... @@ -1,8 +1,6 @@
1   -(defproject lein-javac "1.2.1-SNAPSHOT"
  1 +(defproject lein-javac "1.2.2-SNAPSHOT"
2 2 :description "Java compiler plugin for Leiningen."
3   - :dependencies [[ant/ant-launcher "1.6.5"]
4   - [org.clojure/clojure "1.2.0"]
5   - [org.clojure/clojure-contrib "1.2.0"]]
6   - :dev-dependencies [[leiningen/leiningen "1.3.0-SNAPSHOT"]
7   - [robert/hooke "1.0.2"]
8   - [swank-clojure "1.2.1"]])
  3 + :dependencies [[ant/ant-launcher "1.6.5"]]
  4 + :dev-dependencies [[leiningen/leiningen "1.6.2-SNAPSHOT"]
  5 + [org.clojure/clojure "1.2.1"]
  6 + [robert/hooke "1.1.2"]])
5 src/leiningen/hooks/javac.clj
... ... @@ -1,6 +1,6 @@
1 1 (ns leiningen.hooks.javac
2 2 (:require leiningen.clean leiningen.compile)
3   - (:use [clojure.contrib.io :only [file delete-file delete-file-recursively]]
  3 + (:use [clojure.java.io :only [file delete-file]]
4 4 [leiningen.javac :only (javac extract-javac-tasks)]
5 5 robert.hooke))
6 6
@@ -8,7 +8,8 @@
8 8 (apply task args)
9 9 (doseq [task (extract-javac-tasks (first args))]
10 10 (if-let [directory (:destdir task)]
11   - (delete-file-recursively directory true))))
  11 + (doseq [file (file-seq (java.io.File. directory))]
  12 + (delete-file file true)))))
12 13
13 14 (defn compile-javac-hook [task & args]
14 15 (apply javac args)
17 src/leiningen/javac.clj
@@ -7,18 +7,16 @@ Usage:
7 7 lein javac PATH - Compile only java sources in PATH.
8 8 "
9 9 (:import org.apache.tools.ant.types.Path java.io.File)
10   - (:use [clojure.contrib.def :only (defvar)]
11   - [clojure.contrib.string :only (split join)]
12   - [leiningen.classpath :only (get-classpath make-path)])
  10 + (:use [clojure.string :only (join)]
  11 + [leiningen.classpath :only (get-classpath)])
13 12 (:require lancet)
14 13 (:refer-clojure :exclude [compile]))
15 14
16   -(defvar *java-options*
17   - {:debug "false" :fork "true" :includejavaruntime "yes" :target "1.5"}
18   - "The default options for the java compiler.")
  15 +(def ^{:dynamic true} *java-options*
  16 + {:debug "false" :fork "true" :includejavaruntime "yes"})
19 17
20 18 (defmethod lancet/coerce [Path String] [_ str]
21   - (Path. lancet/ant-project str))
  19 + (Path. lancet/ant-project str))
22 20
23 21 (defn expand-path
24 22 "Expand a path fragment relative to the project root. If path starts
@@ -61,8 +59,7 @@ Usage:
61 59 (lancet/mkdir {:dir (:destdir task-spec)})
62 60 (lancet/javac task-spec))
63 61
64   -(defn javac [project & [directory]]
  62 +(defn javac [project & [directory]]
65 63 (doseq [task (extract-javac-tasks project)
66   - :when (or (nil? directory) (= (expand-path project directory) (:srcdir task)))]
  64 + :when (or (nil? directory) (= (expand-path project directory) (:srcdir task)))]
67 65 (run-javac-task task)))
68   -
50 test/leiningen/test/javac.clj
@@ -2,63 +2,61 @@
2 2 (:import java.io.File)
3 3 (:require leiningen.hooks.javac)
4 4 (:use [leiningen.core :only (defproject read-project)]
5   - [leiningen.classpath :only (get-classpath make-path)]
  5 + [leiningen.classpath :only (get-classpath)]
6 6 [leiningen.clean :only (clean)]
7   - [clojure.contrib.def :only (defvar)]
8 7 clojure.test
9 8 leiningen.javac
10 9 leiningen.test.helper))
11 10
12 11 (refer-private 'leiningen.javac)
13 12
14   -(defvar *project* (read-project "sample/project.clj")
15   - "The sample project file.")
  13 +(def project (read-project "sample/project.clj"))
16 14
17 15 (defn- java-src-task []
18   - (extract-javac-task *project* (first (:java-source-path *project*))))
  16 + (extract-javac-task project (first (:java-source-path project))))
19 17
20 18 (defn- java-test-task []
21   - (extract-javac-task *project* (second (:java-source-path *project*))))
  19 + (extract-javac-task project (second (:java-source-path project))))
22 20
23 21 (defn- main-class-file []
24   - (File. (str (expand-path *project* (:destdir (java-src-task)))
  22 + (File. (str (expand-path project (:destdir (java-src-task)))
25 23 File/separator "Main.class")))
26 24
27 25 (defn- test-class-file []
28   - (File. (str (expand-path *project* (:destdir (java-test-task)))
  26 + (File. (str (expand-path project (:destdir (java-test-task)))
29 27 File/separator "MainTest.class")))
30 28
31 29 (defn- compile-directory []
32   - (File. (expand-path *project* (:compile-path *project*))))
  30 + (File. (expand-path project (:compile-path project))))
33 31
34 32 (defn- cleanup-classes []
35 33 (map #(.delete %) [(main-class-file) (test-class-file)]))
36 34
37   -(deftest test-expand-path
38   - (is (= (expand-path *project* "/tmp")
  35 +(deftest test-expand-path
  36 + (is (= (expand-path project "/tmp")
39 37 "/tmp"))
40   - (is (= (expand-path *project* "src")
41   - (str (:root *project*) File/separator "src"))))
  38 + (is (= (expand-path project "src")
  39 + (str (:root project) File/separator "src"))))
42 40
43   -(deftest test-extract-javac-task
  41 +(deftest test-extract-javac-task
44 42 (are [specs expected]
45   - (is (= (extract-javac-task *project* specs) (merge (java-options *project*) expected)))
  43 + (is (= (extract-javac-task project specs) (merge (java-options project) expected)))
46 44 ["src/java"]
47   - {:classpath (classpath *project*)
48   - :destdir (expand-path *project* (:compile-path *project*))
49   - :srcdir (expand-path *project* "src/java")}
  45 + {:classpath (classpath project)
  46 + :destdir (expand-path project (:compile-path project))
  47 + :srcdir (expand-path project "src/java")}
50 48 ["src/java" :debug "true"]
51   - {:classpath (classpath *project*)
52   - :destdir (expand-path *project* (:compile-path *project*))
  49 + {:classpath (classpath project)
  50 + :destdir (expand-path project (:compile-path project))
53 51 :debug "true"
54   - :srcdir (expand-path *project* "src/java")}))
  52 + :srcdir (expand-path project "src/java")}))
55 53
56 54 (deftest test-extract-javac-tasks
57   - (is (= (extract-javac-tasks *project*) [(java-src-task) (java-test-task)])))
  55 + (is (= (extract-javac-tasks project) [(java-src-task) (java-test-task)])))
58 56
59 57 (deftest test-java-options
60 58 (is (= (java-options {}) *java-options*))
61   - (is (= (java-options *project*) (assoc *java-options* :debug "true"))))
  59 + (is (= (java-options project) (assoc *java-options* :debug "true"))))
62 60
63 61 (deftest test-run-javac-task
64 62 (let [task-spec (java-src-task)]
@@ -72,7 +70,7 @@
72 70 (deftest test-javac
73 71 (try
74 72 (cleanup-classes)
75   - (javac *project*)
  73 + (javac project)
76 74 (is (.exists (compile-directory)))
77 75 (is (.exists (main-class-file)))
78 76 (is (.exists (test-class-file)))
@@ -80,10 +78,10 @@
80 78
81 79 (deftest test-clean-hook
82 80 (try
83   - (javac *project*)
  81 + (javac project)
84 82 (is (.exists (main-class-file)))
85 83 (is (.exists (test-class-file)))
86   - (clean *project*)
  84 + (clean project)
87 85 (is (not (.exists (main-class-file))))
88 86 (is (not (.exists (test-class-file))))
89 87 (finally (cleanup-classes))))

0 comments on commit ca6856f

Please sign in to comment.
Something went wrong with that request. Please try again.