1
votes

I'm trying to write a plugin for Intellij in Clojure. To that end I want to implement some extension endpoints with Clojure's :gen-class functionality. I've added the gradle-clojure plugin and placed some Clojure code in src/main/clojure. But when I build the project it says

> Task :compileClojure SKIPPED

Why is that?

Also, on a related note: If I add the expression (throw (Exception. "abort")) to the Clojure code on the top level, I can crash the build. This doesn't make sense to me. Why would Clojure code get executed during the build?

1

1 Answers

2
votes

In Clojure, pre-compilation is not required. The source code can be compiled when running for the first time, as long as the source is bundled in the .jar file.

For gradle-clojure specifically, the default build task will run checkClojure, which will call the Clojure load function on each source directory, which loads all the namespaces. When you load a namespace, its expressions are executed in order. Normally you'd only put def or defn which would just define global variables. This is done to ensure there's no compiler errors before bundling in the .jar.

The gradle-clojure compileClojure task will only compile the namespaces that are configured with the aotNamespaces or all of them if using aotAll(). In that case it will call the Clojure compile on each namespace. See the gradle-clojure documentation for more info.

For more detail about Clojure compilation, see this documentation