【问题标题】:could not find property on root project gradle for custom task在根项目 gradle 上找不到自定义任务的属性
【发布时间】:2015-03-17 11:30:06
【问题描述】:

我编写了一个自定义任务copyDocs 将构建输出复制到其他目录,并在dependsOn 中给出了此任务,如下所示:

task doit(dependsOn: ['clean', 'build', 'copyDocs'])
build.mustRunAfter clean
copyDocs.mustRunAfter build
....
....
task copyDocs(type: Copy) {
     from 'build/libs'
     into 'build'
 }

上面是自定义任务doit,它必须按照使用mustRunAfter 定义的顺序执行cleanbuildcopyDocs。但它在执行过程中会出错。

During execution (i.e. cmd>gradle doit), I am getting the following error:

* What went wrong:
A problem occurred evaluating script.
> Could not find property 'copyDocs' on root project 'gradle'.
BUILD FAILED

请帮忙解决这个问题。

【问题讨论】:

  • 请在写copyDocs.mustRunAfter build之前尝试定义task copyDocs

标签: java build gradle build.gradle


【解决方案1】:

您收到此错误是因为在执行copyDocs.mustRunAfter 时没有定义名为copyDocs 的任务。 您应该将copyDocs 任务定义放在copyDocs.mustRunAfter build 语句之前。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-14
    • 2013-01-09
    • 2018-05-16
    • 2017-05-02
    • 2018-08-24
    • 2014-08-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多