我想在gradle中覆盖测试任务(此时我正在使用Gradle 4.3版本)来更改此任务的行为。
具体来说,我在Scala项目中使用scoverage gradle插件,我想同时执行$ gradle test
来调用test task和testScoverage任务。
我将task test(overwrite: true) << { testScoverage }
语句附加到build.gradle
文件的最后一个,但我总是收到相同的消息:
gradle test
> 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.
at build_clmw9wbi7768vkj4j7g7sy8v2.run(C:\Users\sergio_rodriguez\Repositorios\my-autodevops-poc\build.gradle:52)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
我假装在单个语句中生成覆盖率报告,以便能够使用Auto Devops Gitlab。
我该怎么做?
我的build.gradle
文件如下:
group 'org.microservices.architecture'
version '1.0-SNAPSHOT'
apply plugin: 'distribution'
apply plugin: 'scala'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.scoverage:gradle-scoverage:2.1.0'
}
}
apply plugin: "org.scoverage"
repositories {
mavenCentral()
}
ext {
scalaVersion = '2.12'
akkaVersion = '2.5.4'
akkaHttVersion = '10.0.9'
}
dependencies {
compile 'org.scala-lang:scala-library:' + scalaVersion + '.1'
compile 'com.typesafe.akka:akka-actor_' + scalaVersion + ':' + akkaVersion
compile 'com.typesafe.akka:akka-stream_' + scalaVersion + ':' + akkaVersion
compile 'com.typesafe.akka:akka-http_' + scalaVersion + ':' + akkaHttVersion
compile 'com.typesafe.akka:akka-http-spray-json_' + scalaVersion + ':' + akkaHttVersion
compile 'ch.qos.logback:logback-classic:1.1.11'
compile 'com.typesafe.akka:akka-slf4j_' + scalaVersion + ':' + akkaVersion
compile 'com.typesafe.akka:akka-http-testkit_' + scalaVersion + ':' + akkaHttVersion
scoverage 'org.scoverage:scalac-scoverage-plugin_2.12:1.3.1', 'org.scoverage:scalac-scoverage-runtime_2.12:1.3.1'
testCompile 'junit:junit:4.12'
testCompile 'org.scalatest:scalatest_' + scalaVersion + ':3.0.1'
testCompile 'com.typesafe.akka:akka-http-testkit_' + scalaVersion + ':' + akkaHttVersion
}
sourceSets.main.scala.srcDir 'src/main/scala'
sourceSets.test.scala.srcDir 'src/test/scala'
task wrapper(type: Wrapper) {
gradleVersion = '4.3'
}
task stage(dependsOn: ['installDist'])
task test(overwrite: true) << { testScoverage }