在gradle中执行clojure脚本

时间:2016-12-14 12:25:51

标签: gradle clojure clojuresque

我有这样的项目结构

build.gradle

root buildscript { dependencies { classpath "clojuresque:clojuresque-base:$clojuresqueVersion" } repositories { jcenter() maven { url 'http://clojars.org/repo' } } } allprojects { apply plugin: 'idea' repositories { mavenCentral() jcenter() } group='com.lapots.functional' } 看起来像这样

build.gradle

子项目apply plugin: 'clojure-min' clojure { aotCompile = true warnOnReflection = true } repositories { clojarsRepo() } dependencies { compile "org.clojure:clojure:$clojureVersion" } 看起来像这样

clojure

我有简单的script.clj脚本(ns com.lapots.functional.clojure.script) (defn -main [& args] (println "Hello, world!"))

{{1}}

但是如何用gradle运行呢?

1 个答案:

答案 0 :(得分:0)

我选择了那个解决方案。 添加了:gen-class

(ns com.lapots.functional.clojure.script
    (:gen-class))

(defn -main [& args]
      (println "Hello, world!"))

创建了gradle任务

task runClojure(dependsOn: classes, type: JavaExec) {
    main = 'com.lapots.functional.clojure.script'
    classpath = sourceSets.main.runtimeClasspath
}

然后用gradle runClojure运行它。