0

I've got project structure like this

functional-lore
    clojure-project
         src\main\clojure\com.lapots.functional.clojure
             script.clj
         build.gradle
build.gradle

Where root build.gradle looks like this

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'
}

And subproject build.gradle looks like this

apply plugin: 'clojure-min'

clojure {
    aotCompile = true
    warnOnReflection = true
}

repositories {
    clojarsRepo()
}

dependencies {
    compile "org.clojure:clojure:$clojureVersion"
}

And I have simple clojure script script.clj

(ns com.lapots.functional.clojure.script)

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

But how to run it with gradle?

lapots
  • 12,553
  • 32
  • 121
  • 242

1 Answers1

0

I went with that solution. Added :gen-class.

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

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

Created gradle task

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

And then just ran it with gradle runClojure.

lapots
  • 12,553
  • 32
  • 121
  • 242