In my Leiningen project:
(defproject com.stackoverflow.clojure/tests "0.1.0-SNAPSHOT" :description "Tests of Clojure test-framework." :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.6.0"] [instaparse "1.3.4"]] :aot [com.stackoverflow.clojure.testGenClass] :source-paths ["src/main/clojure"] :java-source-paths ["src/main/java"] :test-paths ["src/test/clojure"] :java-test-paths ["src/test/java"] ) I'm generating Java-classes with gen-class:
(ns com.stackoverflow.clojure.testGenClass (:gen-class :name com.stackoverflow.clojure.TestGenClass :implements [com.stackoverflow.clojure.TestGenClassInterface] :prefix "java-")) (def ^:private pre "START: ") (defn java-addToString [this text post] (str pre text post)) which I want to use in Java:
package com.stackoverflow.clojure; public class TestGenClassTest { private TestGenClassTest() { } public static void main(String[] args) { TestGenClassInterface gc = new TestGenClass(); System.out.println(gc.addToString("Called from Java!", " :END")); } } Starting lein compile throws the following error:
Compiling 4 source files to /home/eddy/workspace/TestSkripts/target/classes /home/eddy/workspace/TestSkripts/src/main/java/com/stackoverflow/clojure/TestGenClassTest.java:9: error: cannot find symbol TestGenClassInterface gc = new TestGenClass(); ^ symbol: class TestGenClass location: class TestGenClassTest 1 error It seems to me, that during compilation of the Java-code (here: TestGenClassTest) the Class is not available. What I usually did is
- commenting out those parts that use the gen-class generated class (here
TestGenClass) - run
lein compile(to generate the class-file) - then taking the outcommented code in again
- and run
lein compileagain.
I' sure there is a better way, that makes all manual steps redundat.