Permalink
Browse files

Got rid of contrib dependencies.

  • Loading branch information...
1 parent f0546c6 commit ca6856f59c7872a4df0e33a7cbaed264d5f81ec3 Roman Scherer committed Feb 14, 2012
Showing with 41 additions and 45 deletions.
  1. +2 −0 .gitignore
  2. +5 −7 project.clj
  3. +3 −2 src/leiningen/hooks/javac.clj
  4. +7 −10 src/leiningen/javac.clj
  5. +24 −26 test/leiningen/test/javac.clj
View
@@ -3,3 +3,5 @@ lib
*~
pom.xml
*.jar
+/.lein-deps-sum
+/.lein-failures
View
@@ -1,8 +1,6 @@
-(defproject lein-javac "1.2.1-SNAPSHOT"
+(defproject lein-javac "1.2.2-SNAPSHOT"
:description "Java compiler plugin for Leiningen."
- :dependencies [[ant/ant-launcher "1.6.5"]
- [org.clojure/clojure "1.2.0"]
- [org.clojure/clojure-contrib "1.2.0"]]
- :dev-dependencies [[leiningen/leiningen "1.3.0-SNAPSHOT"]
- [robert/hooke "1.0.2"]
- [swank-clojure "1.2.1"]])
+ :dependencies [[ant/ant-launcher "1.6.5"]]
+ :dev-dependencies [[leiningen/leiningen "1.6.2-SNAPSHOT"]
+ [org.clojure/clojure "1.2.1"]
+ [robert/hooke "1.1.2"]])
@@ -1,14 +1,15 @@
(ns leiningen.hooks.javac
(:require leiningen.clean leiningen.compile)
- (:use [clojure.contrib.io :only [file delete-file delete-file-recursively]]
+ (:use [clojure.java.io :only [file delete-file]]
[leiningen.javac :only (javac extract-javac-tasks)]
robert.hooke))
(defn clean-javac-hook [task & args]
(apply task args)
(doseq [task (extract-javac-tasks (first args))]
(if-let [directory (:destdir task)]
- (delete-file-recursively directory true))))
+ (doseq [file (file-seq (java.io.File. directory))]
+ (delete-file file true)))))
(defn compile-javac-hook [task & args]
(apply javac args)
@@ -7,18 +7,16 @@ Usage:
lein javac PATH - Compile only java sources in PATH.
"
(:import org.apache.tools.ant.types.Path java.io.File)
- (:use [clojure.contrib.def :only (defvar)]
- [clojure.contrib.string :only (split join)]
- [leiningen.classpath :only (get-classpath make-path)])
+ (:use [clojure.string :only (join)]
+ [leiningen.classpath :only (get-classpath)])
(:require lancet)
(:refer-clojure :exclude [compile]))
-(defvar *java-options*
- {:debug "false" :fork "true" :includejavaruntime "yes" :target "1.5"}
- "The default options for the java compiler.")
+(def ^{:dynamic true} *java-options*
+ {:debug "false" :fork "true" :includejavaruntime "yes"})
(defmethod lancet/coerce [Path String] [_ str]
- (Path. lancet/ant-project str))
+ (Path. lancet/ant-project str))
(defn expand-path
"Expand a path fragment relative to the project root. If path starts
@@ -61,8 +59,7 @@ Usage:
(lancet/mkdir {:dir (:destdir task-spec)})
(lancet/javac task-spec))
-(defn javac [project & [directory]]
+(defn javac [project & [directory]]
(doseq [task (extract-javac-tasks project)
- :when (or (nil? directory) (= (expand-path project directory) (:srcdir task)))]
+ :when (or (nil? directory) (= (expand-path project directory) (:srcdir task)))]
(run-javac-task task)))
-
@@ -2,63 +2,61 @@
(:import java.io.File)
(:require leiningen.hooks.javac)
(:use [leiningen.core :only (defproject read-project)]
- [leiningen.classpath :only (get-classpath make-path)]
+ [leiningen.classpath :only (get-classpath)]
[leiningen.clean :only (clean)]
- [clojure.contrib.def :only (defvar)]
clojure.test
leiningen.javac
leiningen.test.helper))
(refer-private 'leiningen.javac)
-(defvar *project* (read-project "sample/project.clj")
- "The sample project file.")
+(def project (read-project "sample/project.clj"))
(defn- java-src-task []
- (extract-javac-task *project* (first (:java-source-path *project*))))
+ (extract-javac-task project (first (:java-source-path project))))
(defn- java-test-task []
- (extract-javac-task *project* (second (:java-source-path *project*))))
+ (extract-javac-task project (second (:java-source-path project))))
(defn- main-class-file []
- (File. (str (expand-path *project* (:destdir (java-src-task)))
+ (File. (str (expand-path project (:destdir (java-src-task)))
File/separator "Main.class")))
(defn- test-class-file []
- (File. (str (expand-path *project* (:destdir (java-test-task)))
+ (File. (str (expand-path project (:destdir (java-test-task)))
File/separator "MainTest.class")))
(defn- compile-directory []
- (File. (expand-path *project* (:compile-path *project*))))
+ (File. (expand-path project (:compile-path project))))
(defn- cleanup-classes []
(map #(.delete %) [(main-class-file) (test-class-file)]))
-(deftest test-expand-path
- (is (= (expand-path *project* "/tmp")
+(deftest test-expand-path
+ (is (= (expand-path project "/tmp")
"/tmp"))
- (is (= (expand-path *project* "src")
- (str (:root *project*) File/separator "src"))))
+ (is (= (expand-path project "src")
+ (str (:root project) File/separator "src"))))
-(deftest test-extract-javac-task
+(deftest test-extract-javac-task
(are [specs expected]
- (is (= (extract-javac-task *project* specs) (merge (java-options *project*) expected)))
+ (is (= (extract-javac-task project specs) (merge (java-options project) expected)))
["src/java"]
- {:classpath (classpath *project*)
- :destdir (expand-path *project* (:compile-path *project*))
- :srcdir (expand-path *project* "src/java")}
+ {:classpath (classpath project)
+ :destdir (expand-path project (:compile-path project))
+ :srcdir (expand-path project "src/java")}
["src/java" :debug "true"]
- {:classpath (classpath *project*)
- :destdir (expand-path *project* (:compile-path *project*))
+ {:classpath (classpath project)
+ :destdir (expand-path project (:compile-path project))
:debug "true"
- :srcdir (expand-path *project* "src/java")}))
+ :srcdir (expand-path project "src/java")}))
(deftest test-extract-javac-tasks
- (is (= (extract-javac-tasks *project*) [(java-src-task) (java-test-task)])))
+ (is (= (extract-javac-tasks project) [(java-src-task) (java-test-task)])))
(deftest test-java-options
(is (= (java-options {}) *java-options*))
- (is (= (java-options *project*) (assoc *java-options* :debug "true"))))
+ (is (= (java-options project) (assoc *java-options* :debug "true"))))
(deftest test-run-javac-task
(let [task-spec (java-src-task)]
@@ -72,18 +70,18 @@
(deftest test-javac
(try
(cleanup-classes)
- (javac *project*)
+ (javac project)
(is (.exists (compile-directory)))
(is (.exists (main-class-file)))
(is (.exists (test-class-file)))
(finally (cleanup-classes))))
(deftest test-clean-hook
(try
- (javac *project*)
+ (javac project)
(is (.exists (main-class-file)))
(is (.exists (test-class-file)))
- (clean *project*)
+ (clean project)
(is (not (.exists (main-class-file))))
(is (not (.exists (test-class-file))))
(finally (cleanup-classes))))

0 comments on commit ca6856f

Please sign in to comment.