在 gradle 的构建任务中对编译任务重新排序



我正试图在如下目录结构中构建我的项目,该项目具有一些java源代码和clojure源代码:

src
`-- main
|-- clojure
|   `-- appc
|       `-- core.clj
`-- java
`-- appj
`-- AppStarter.java

我已经在我的gradle构建文件中加载了javaclojureapplication插件。Clojure插件来自https://bitbucket.org/kotarak/clojuresque/overview,版本1.5.2.

这里,clojure代码core.clj的代码使用了用java编写的类。但是java源代码中没有任何内容依赖于clojure代码。

现在,当我做gradle tasks --all时,我看到

...
classes - Assembles the main classes.
compileClojure - Compile the main Clojure source.
compileJava - Compiles the main Java source.
processResources - Processes the main resources.
...

因此,build任务将首先编译clojure源代码,然后编译java源代码。这显然不起作用,因为clojure代码依赖于java部分。所以我需要compileJava发生在compileClojure之前。

更改应用clojurejava插件的顺序没有任何效果。

由于clojure插件是新的,我试用了groovyscala插件。我在每种情况下都得到了以下内容。

...
classes - Assembles the main classes.
compileGroovy - Compile the main Groovy source.
compileJava - Compiles the main Java source.
processResources - Processes the main resources.
...

...
classes - Assembles the main classes.
compileJava - Compiles the main Java source.
compileScala - Compile the main Scala source.
processResources - Processes the main resources.
...

我想应该有办法重新订购这些吧?我在文档中找不到(尽管它们真的很好!)。有没有办法告诉gradle先编译我的java源代码build,然后编译clojure源代码?

获得正确的订单就像compileClojure.dependsOn(compileJava)一样简单。另一个问题是Java类是否正确地放置在Clojure编译器的类路径上。

PS:gradle tasks输出中的任务顺序没有说明任务执行的顺序。任务执行的顺序完全由任务相关性决定。

最新更新