我想覆盖 gradle 中的测试任务(我现在使用的是 Gradle 4.3 版本)来改变这个任务的行为。
具体来说,我在 Scala 项目中使用 scoverage gradle 插件,我想同时执行$ gradle test
调用测试任务和 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 }