I am trying to build my project that has some java source and clojure source code, in a directory structure like the following:
src
`-- main
|-- clojure
| `-- appc
| `-- core.clj
`-- java
`-- appj
`-- AppStarter.java
I have loaded the java
, clojure
and application
plugins in my gradle build file. Clojure plugin is from https://bitbucket.org/kotarak/clojuresque/overview, version 1.5.2.
Here, the clojure code, core.clj
, has code that uses the classes written in java. But there is nothing in the java source that depends on the clojure code.
Now, when I do gradle tasks --all
, I see
...
classes - Assembles the main classes.
compileClojure - Compile the main Clojure source.
compileJava - Compiles the main Java source.
processResources - Processes the main resources.
...
So, the build
task will compile my clojure sources first and then the java sources. This obviously doesn't work, because the clojure code depends on the java part. So I need compileJava
to happen before compileClojure
.
Changing the order of applying the clojure
and java
plugins didn't have any effect.
Since the clojure plugin is new, I tried out with the groovy
and scala
plugins. I got the following in each case.
...
classes - Assembles the main classes.
compileGroovy - Compile the main Groovy source.
compileJava - Compiles the main Java source.
processResources - Processes the main resources.
...
and
...
classes - Assembles the main classes.
compileJava - Compiles the main Java source.
compileScala - Compile the main Scala source.
processResources - Processes the main resources.
...
I suppose there should be a way to reorder these right? I couldn't find out in the docs (despite them being really good!). Is there any way to tell gradle to compile my java sources build first, and then compile the clojure sources?
Getting the order right is as simple as compileClojure.dependsOn(compileJava)
. The other question is if the Java classes are correctly placed on the Clojure compiler's class path.
PS: The order of tasks in the gradle tasks
output says nothing about the order in which the tasks execute. Order of task execution is entirely determined by task dependencies.