1

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

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

我已经在我的 gradle 构建文件中加载了java,clojureapplication插件。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插件是新的,我尝试了groovyandscala插件。在每种情况下,我都得到了以下信息。

...
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 源代码构建,然后再编译 clojure 源代码?

4

1 回答 1

3

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

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

于 2012-10-15T16:11:08.123 回答