2

我尝试build.gradle使用以下命令运行任务:

gradle footype

但是构建失败并显示了我要修复的这两个错误消息:

> Configure project : 
The Task.leftShift(Closure) method has been deprecated and is scheduled to 
be removed in Gradle 5.0. Please use Task.doLast(Action) instead.

还有这个消息:

* What went wrong:
An exception occurred applying plugin request [id: 'java']
> Failed to apply plugin [class         
'org.gradle.language.base.plugins.LifecycleBasePlugin']
   > Declaring custom 'assemble' task when using the standard Gradle 
lifecycle plugins is not allowed.

这是build.gradle文件的代码:

plugins{
  id "com.gradle.build-scan" version "1.10.2"
  id "org.arquillian.spacelift" version "1.0.0-alpha-17"
  id "java"
}

group 'k'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
  mavenCentral()
}

task fooType {
  doLast {
    def foo = "bar"
    println "$foo + foo = ${foo + "foo"}"
  }
}

我搜索了其他帖子,他们似乎都提到了一个名为 clean() 的任务,它没有出现在我的代码中,所以我想知道问题出在哪里。

非常感谢您阅读这篇文章。

4

1 回答 1

0

当谈到这条消息时:

配置项目:Task.leftShift(Closure) 方法已被弃用,并计划在 Gradle 5.0 中删除。请改用 Task.doLast(Action)。

it is just a warning. It states that one (possibly more) plugin you applied uses << which will be removed in version 5.0 of gradle in favour of doLast. You are not using << directly in your script and that's ok. To eliminate this warning first of all you need to know which plugin uses it, then raise an issue on plugin's site asking for deprecated code elimination.

When it comes to the second message it's an error and in single build script nothing can be done about it. Two plugins java and org.arquillian.spacelift have declared a task with the same name (it's assemble) - this is a conflict. Maybe you can split you project into a multimodule?

于 2017-11-14T06:42:35.440 回答