gpt4 book ai didi

gradle - 更新到 Gradle 5.0 后烦人的弹窗提示

转载 作者:行者123 更新时间:2023-12-02 12:28:55 25 4
gpt4 key购买 nike

刚刚更新到 Gradle 5.0,现在我得到了这个 pop-up hints :

buildscript {

ext.kotlin_version = '1.3.10'

repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // 'classpath' in 'org.gradle.api.artifacts.dsl.DependencyHandler' cannot be applied to '(groovy.lang.GString)'
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
classpath "org.junit.platform:junit-platform-gradle-plugin:1.2.0"
}
}

plugins {
id 'maven'
id "org.jetbrains.kotlin.jvm" version "1.3.10"
id "com.github.johnrengelman.shadow" version "2.0.4"
}

ext.moduleName = 'com.github.kotlin_graphics.kotlin_unsigned'

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // 'implementation' in 'org.gradle.api.artifacts.dsl.DependencyHandler' cannot be applied to '(groovy.lang.GString)'

testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.1.10'
}

repositories {
mavenCentral()
maven { url = "https://dl.bintray.com/kotlin/kotlin-eap" }
maven { url = "https://jitpack.io" }
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives sourcesJar
archives javadocJar
}

jar {
inputs.property("moduleName", moduleName)
manifest { // here
attributes('Automatic-Module-Name': moduleName)
}
}

test {
useJUnitPlatform()
}

为什么?我该如何解决?

最佳答案

您无需担心真正的实际问题。根据您更新的问题和屏幕截图,您弹出了一个不正确的 IDE 静态分析提示。您没有收到来自 Gradle 的任何错误或警告消息。您的文本编辑器中有一些误导性的东西。

当您显示的代码(例如,您的 build.gradle 是 Groovy 代码)无法完全解释以了解正确的类型时,有时会发生这种情况。在这种情况下,没有错。这是一条红鲱鱼,应该被忽略。

您可以安全地忽略此 IDE 消息,您有时会在 build.gradle 文件中收到其他误导性消息。如果您需要正确的 IDE 帮助编写构建文件,请切换到完全类型安全的 Kotlin 版本的 gradle 构建文件。对于您收到的消息,Groovy 版本在 IDE 中从来都不是完美的。

在空目录上测试你的build.gradle:

$ ./gradlew build

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 0s
7 actionable tasks: 2 executed, 5 up-to-date

并直接从您的 GitHub 存储库对其进行测试:(注意:您在应该解决的警告中存在一些危险的类路径问题)

$ ./gradlew clean build
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/Users/xyz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.2.50/9fab8887f91c8e17cce1a7522f45dc25976e57b9/kotlin-reflect-1.2.50.jar (version 1.2)
/Users/xyz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.2.31/95d6a67e8787280a82a2059e54e4db7ac6cfe74/kotlin-stdlib-jdk7-1.2.31.jar (version 1.2)
/Users/xyz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.10/b178c1501609c6e4ee8be635513cb023a466457d/kotlin-stdlib-1.3.10.jar (version 1.3)
/Users/xyz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.10/1b19d99229dcedad7caf50534dce38fe82845269/kotlin-stdlib-common-1.3.10.jar (version 1.3)
w: Consider providing an explicit dependency on kotlin-reflect 1.3 to prevent strange errors
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath

> Task :test FAILED

unsigned.Ubyte test > ubyte FAILED
org.opentest4j.AssertionFailedError at ubyte.kt:35

unsigned.Uint test > uint FAILED
org.opentest4j.AssertionFailedError at uint.kt:32

unsigned.Ulong test > ulong FAILED
org.opentest4j.AssertionFailedError at ulong.kt:29

unsigned.Ushort test > ushort FAILED
org.opentest4j.AssertionFailedError at ushort.kt:30

6 tests completed, 4 failed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///Users/xyz/.../kotlin-unsigned/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5s
10 actionable tasks: 10 executed

请注意,Gradle 不会报告任何消息或错误。只有您的 IDE 是。

关于gradle - 更新到 Gradle 5.0 后烦人的弹窗提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53496317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com