此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 5.0 不兼容 [英] Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0
问题描述
我有一个 gradle 失败:
I've got a gradle FAILURE:
..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0."
案例描述:
- 附加到项目代码库的下一个库:
APP/build.gradle
//(Required) Writing and executing Unit Tests on the JUnit Platform
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
// (Optional) If you need "Parameterized Tests"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.2.0"
// (Optional) If you also have JUnit 4-based tests
testImplementation "junit:junit:4.12"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.2.0"
testImplementation "io.mockk:mockk:1.8.5"
更新了gradle-wrapper.properties
distributionUrl=https....gradle-4.4-all.zip 到 4.7-all
distributionUrl=https....gradle-4.4-all.zip to 4.7-all
在所有 gradle 构建成功之后
after all of that gradle was built success
创建测试类
@TestInstance(TestInstance.Lifecycle.PER_CLASS) class TestClass { @Test internal fun testName() { Assert.assertEquals(2, 1 + 1) } }
运行测试并收到 FAILURE 消息.
ran the test and got the FAILURE message.
使用命令行参数
./gradlew --warning-mode=all
运行 Gradle 构建以查看不推荐使用的功能究竟是什么.ran the Gradle build with a command line argument
./gradlew --warning-mode=all
to see what exactly the deprecated features are.因此,我无法构建应用程序,并且收到了 FAILURE: 消息.
As a result I couldn't build the app and I've got that FAILURE: message.
推荐答案
使用命令行参数运行 Gradle 构建
--warning-mode=all
以查看不推荐使用的功能究竟是什么.Run the Gradle build with a command line argument
--warning-mode=all
to see what exactly the deprecated features are.它将为您提供所发现问题的详细说明,并提供指向 Gradle 文档的链接,以获取有关如何修复您的构建的说明.
It will give you a detailed description of found issues with links to the Gradle docs for instructions how to fix your build.
向其中添加
--stacktrace
,如果警告是由插件之一中的过时代码而不是您的构建脚本触发的,您还可以查明警告的来源.Adding
--stacktrace
to that, you will also be able to pinpoint where the warning comes from, if it's triggered by outdated code in one of the plugins and not your build script.这篇关于此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 5.0 不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!