Skip to content

Commit

Permalink
Fixed lein-javac for Leiningen 1.7.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Scherer committed Feb 15, 2012
1 parent 21fafc1 commit 37b66d1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
16 changes: 12 additions & 4 deletions README
Expand Up @@ -20,9 +20,9 @@ Example:
:dependencies [[org.clojure/clojure "1.2.0-beta1"]]
:dev-dependencies [[lein-javac "1.2.1-SNAPSHOT"]]
:source-path "src/clojure"
:java-source-path [["src/java"]
["test/java" :debug "true"]]
:java-options {:debug "true"})
:javac-source-path [["src/java"]
["test/java" :debug "true"]]
:javac-options {:debug "true"})

## Compilation

Expand All @@ -40,6 +40,15 @@ Use Leiningen and add lein-javac to your development dependencies.

:dev-dependencies [[lein-javac "1.2.1-SNAPSHOT"]]

## Leiningen's built-in "javac" task

Leiningen has a built in "javac" task, that was derived from
lein-javac. Unfortunately most of the lein-javac features have been
stripped out over the time :(

Use the :javac-source-path and :javac-options keywords if you want to
use lein-javac, otherwise just :java-source-path and :java-options.

## Authors

- Caspar Florian Ebeling / febeling
Expand All @@ -49,4 +58,3 @@ Use Leiningen and add lein-javac to your development dependencies.
## License

EPL license

4 changes: 2 additions & 2 deletions project.clj
@@ -1,5 +1,5 @@
(defproject org.clojars.r0man/lein-javac "1.2.4-SNAPSHOT"
(defproject lein-javac "1.3.0"
:description "Java compiler plugin for Leiningen."
:dependencies [[ant/ant-launcher "1.6.5"]]
:dev-dependencies [[leiningen/leiningen "1.6.2"]
:dev-dependencies [[leiningen/leiningen "1.7.0"]
[robert/hooke "1.1.2"]])
7 changes: 4 additions & 3 deletions sample/project.clj
Expand Up @@ -8,7 +8,8 @@
:dev-dependencies [[lein-javac "1.2.1-SNAPSHOT"]]
:source-path "src/clojure"
:compile-path "build/classes"
:plugins [[lein-javac "0.1.0"]]
:hooks [leiningen.hooks.javac]
:java-source-path [["src/java"]
["test/java" :destdir "build/unit/classes"]]
:java-options {:debug "true"})
:javac-source-path [["src/java"]
["test/java" :destdir "build/unit/classes"]]
:javac-options {:debug "true"})
14 changes: 7 additions & 7 deletions src/leiningen/javac.clj
Expand Up @@ -9,14 +9,14 @@ Usage:
(:import org.apache.tools.ant.types.Path java.io.File)
(:use [clojure.string :only (join)]
[leiningen.classpath :only (get-classpath)])
(:require lancet)
(:require lancet.core)
(:refer-clojure :exclude [compile]))

(def ^{:dynamic true} *java-options*
{:debug "false" :fork "true" :includejavaruntime "yes"})

(defmethod lancet/coerce [Path String] [_ str]
(Path. lancet/ant-project str))
(defmethod lancet.core/coerce [Path String] [_ str]
(Path. lancet.core/ant-project str))

(defn expand-path
"Expand a path fragment relative to the project root. If path starts
Expand All @@ -33,7 +33,7 @@ Usage:

(defn- java-options
"Returns the java compiler options of the project."
[project] (merge *java-options* (:java-options project)))
[project] (merge *java-options* (:javac-options project)))

(defn extract-javac-task
"Extract a compile task from the given spec."
Expand All @@ -49,15 +49,15 @@ Usage:
(defn extract-javac-tasks
"Extract all compile tasks of the project."
[project]
(let [specs (:java-source-path project)]
(let [specs (:javac-source-path project)]
(map #(extract-javac-task project %)
(if (isa? (class specs) String) [[specs]] specs))))

(defn- run-javac-task
"Compile the given task spec."
[task-spec]
(lancet/mkdir {:dir (:destdir task-spec)})
(lancet/javac task-spec))
(lancet.core/mkdir {:dir (:destdir task-spec)})
(lancet.core/javac task-spec))

(defn javac [project & [directory]]
(doseq [task (extract-javac-tasks project)
Expand Down
4 changes: 2 additions & 2 deletions test/leiningen/test/javac.clj
Expand Up @@ -13,10 +13,10 @@
(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 (:javac-source-path project))))

(defn- java-test-task []
(extract-javac-task project (second (:java-source-path project))))
(extract-javac-task project (second (:javac-source-path project))))

(defn- main-class-file []
(File. (str (expand-path project (:destdir (java-src-task)))
Expand Down

0 comments on commit 37b66d1

Please sign in to comment.