Skip to content

Instantly share code, notes, and snippets.

@cemerick
Created January 15, 2012 14:38
Show Gist options
  • Select an option

  • Save cemerick/1616042 to your computer and use it in GitHub Desktop.

Select an option

Save cemerick/1616042 to your computer and use it in GitHub Desktop.
compiling Clojure before Java sources
;; Example from _Clojure Programming_; exposition on it, Leiningen, hooks,
;; and compilation order found therein. http://www.clojurebook.com
(defproject com.clojurebook/lein-mixed-source "1.0.0"
:dependencies [[org.clojure/clojure "1.3.0"]]
:aot :all)
(require '(leiningen compile javac))
(add-hook #'leiningen.compile/compile
(fn [compile project & args]
(apply compile project args)
(leiningen.javac/javac (assoc project :java-source-path "srcj"))))
@vijaykiran
Copy link

Using leiningen 2 I get Unable to resolve symbol: add-hook in this context

This seems to fix it:

(require '(leiningen compile javac))
(require '(robert hooke))

(robert.hooke/add-hook #'leiningen.compile/compile
  (fn [compile project & args]
    (apply compile project args)
    (leiningen.javac/javac (assoc project :java-source-paths ["src/java"]))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment