简体   繁体   中英

how to run the clojure main from gradle application plugin

I've main clojure file -

(ns main.main
  (:gen-class))

(defn -main
      "I don't do a whole lot ... yet."
      [& args]
      (println "Hello, World!"))

I've build.gradle file -

plugins {
    id 'dev.clojurephant.clojure' version '0.7.0-alpha.1'
    id 'application'
}

group 'org.example'
version '0.0.1-SNAPSHOT'
repositories {
    maven {
        name = 'Clojars'
        url = 'https://repo.clojars.org'
    }
    mavenCentral()
}


dependencies {
    implementation 'org.clojure:clojure:1.11.1'

    testRuntimeOnly 'org.ajoberstar:jovial:0.3.0'

    devImplementation 'org.clojure:tools.namespace:1.3.0'
    
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
}

tasks.withType(Test) {
    useJUnitPlatform()
}

application {
    mainClassName("main.main")
}

Now I tried to run the gradle application using command gradle run and encountered below error -

Error: Could not find or load main class main.main

Caused by: java.lang.ClassNotFoundException: main.main

I tried some more application configuration but didn't work -


application {
    mainClass = "clojure.main"
    mainModule = "main.main"
}

what is the correct value of mainClass and mainModule .

Finally got it working. Missed the below config -

clojure {
  builds {
    main {
      aotAll()
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM