如何将任务添加到Gradle中的主“构建”任务 [英] How do I add a task to main 'build' task in gradle
问题描述
rootProject.tasks.getByName( 'build')。dependsOn mytask
当我运行 gradle(w )用输出生成
:
*其中:
构建文件'... '行
:...
*出错:
评估项目':myapp'时发生问题。
>在根项目'main'中找不到名称为'build'的任务。
如何将任务添加到构建任务?
问题是你的构建没有构建
任务,至少在上线被评估时。通常, build
任务被 java-base
插件添加,这些插件又被插件如 java
, groovy
或 scala
。所以请确保首先应用其中一个插件。或者,如果您不使用任何一个,请声明您自己的 build
任务。
When I try to add a task to the main build task with the following code:
rootProject.tasks.getByName('build').dependsOn mytask
It complains when I run gradle(w) build
with the output:
* Where:
Build file '...' line
: ...
* What went wrong:
A problem occurred evaluating project ':myapp'.
> Task with name 'build' not found in root project 'main'.
how do i add the task to the build task?
The problem is that your build has no build
task, at least at the time when above line gets evaluated. Usually, the build
task gets added by the java-base
plugin, which in turns gets applied by plugins such as java
, groovy
, or scala
. So make sure to apply one of these plugins first. Or, if you don't use any of them, declare your own build
task.
这篇关于如何将任务添加到Gradle中的主“构建”任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!