如何在java中提供clojure代码?

时间:2016-07-29 13:35:14

标签: java gradle clojure

在我的Eclipse项目中,我在src/main/clojure/ext/clojuretest/helloworld.clj中有以下Clojure代码:

(ns ext.clojuretest.helloworld)

;; https://clojuredocs.org/clojure.core/gen-class
(gen-class
  :name "ext.clojuretest.HelloWorld"
  :prefix "java-"
  :main true)

(defn java-main [& args]
  "I can say 'Hello World'."
  (println "Hello, World from Clojure!"))
  ;;(.println (System/out) "Hello, World from Java!"))

我想在同一个项目中使用Java代码中的类:src/main/java/ext/clojuretest/ClojureTest.java

package ext.clojuretest;

public class ClojureTest {

    public static void main(String[] args) {
        HelloWorld h = new HelloWorld();
    }

}

我正在使用Gradle构建我的项目(build.gradle):

plugins {
  id "de.kotka.clojuresque.clojure" version "2.0.0"
}

repositories {
  mavenCentral()
}

dependencies {
    compile 'org.clojure:clojure:1.8.0'
}

clojure.aotCompile = true

是否可以在我的Java代码中使用类HelloWorld?目前,编译器找不到HelloWorld

HelloWorld cannot be resolved to a type

0 个答案:

没有答案