Skip to content

Commit

Permalink
Allow multiple Java source paths. Fixes technomancy#155.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Mar 10, 2011
1 parent 270cf1d commit 96ff4ee
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/leiningen/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
identity
args))

(defn- normalize-path [project-root path]
(defn normalize-path [project-root path]
(when path
(let [f (File. path)]
(.getAbsolutePath (if (.isAbsolute f) f (File. project-root path))))))
Expand Down Expand Up @@ -65,8 +65,6 @@
:jar-dir (normalize-path#
(or (:target-dir m#) (:jar-dir m#)
root#))
:java-source-path (normalize-path#
(:java-source-path m#))
:root root#)))
(when (:test-resources-path m#)
(println (str "WARNING: :test-resources-path is deprecated; use "
Expand Down
9 changes: 5 additions & 4 deletions src/leiningen/javac.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns leiningen.javac
"Compile Java source files."
(:use [leiningen.classpath :only [get-classpath-string]])
(:use [leiningen.classpath :only [get-classpath-string]]
[leiningen.core :only [normalize-path]])
(:require [lancet.core :as lancet])
(:import (java.io File)))

Expand All @@ -16,16 +17,16 @@
(merge *default-javac-options*
(:javac-options project)
{:destdir (:compile-path project)
:srcdir path
:srcdir (normalize-path (:root project) path)
:classpath (get-classpath-string project)}
(apply hash-map options)))

(defn- extract-javac-tasks
"Extract all compile tasks of the project."
[project]
(let [specs (:java-source-path project)]
(map #(extract-javac-task project %)
(if (string? specs) [[specs]] specs))))
(for [spec (if (string? specs) [[specs]] specs)]
(extract-javac-task project spec))))

(defn- run-javac-task
"Compile the given task spec."
Expand Down
4 changes: 3 additions & 1 deletion test/leiningen/test/javac.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
(delete-file-recursively "test_projects/dev-deps-only/classes" true)
(javac test-project)
(is (.exists (file "test_projects/dev-deps-only/classes"
"dev_deps_only" "Junk.class"))))
"dev_deps_only" "Junk.class")))
(is (.exists (file "test_projects/dev-deps-only/classes"
"dev_deps_only" "Junk2.class"))))
2 changes: 1 addition & 1 deletion test_projects/dev-deps-only/project.clj
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(defproject dev-deps-only "1.0.0-SNAPSHOT"
:java-source-path "src"
:java-source-path [["src"] ["src2"]]
:dev-dependencies [[org.clojure/clojure "1.2.0"]])
3 changes: 3 additions & 0 deletions test_projects/dev-deps-only/src2/dev_deps_only/Junk2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package dev_deps_only;

class Junk2 {}

0 comments on commit 96ff4ee

Please sign in to comment.