首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在gradle的构建任务中重新排序编译任务

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

Stack Overflow用户
提问于 2012-10-15 15:43:42
回答 1查看 1.9K关注 0票数 1

我试图在目录结构中构建包含一些java源代码和clojure源代码的项目,如下所示:

代码语言:javascript
复制
src
`-- main
    |-- clojure
    |   `-- appc
    |       `-- core.clj
    `-- java
        `-- appj
            `-- AppStarter.java

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

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

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

代码语言:javascript
复制
...
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之前。

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

因为clojure插件是新的,所以我尝试了groovy和scala插件。我在每一件案子中都得到了以下信息。

代码语言:javascript
复制
...
classes - Assembles the main classes.
    compileGroovy - Compile the main Groovy source.
    compileJava - Compiles the main Java source.
    processResources - Processes the main resources.
...

和

代码语言:javascript
复制
...
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源代码?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-15 16:11:08

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

PS:gradle tasks输出中的任务顺序与任务执行的顺序无关。任务执行的顺序完全由任务依赖关系决定。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12899185

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档