gpt4 book ai didi

kotlin - 如何解决此类型不匹配?

转载 作者:行者123 更新时间:2023-12-03 05:21:48 34 4
gpt4 key购买 nike

所以我当时正在将我的build.gradle(使用Groovy的)转换为build.gradle.kts(使用Kotlin的),这是我到目前为止所得到的:
Groovy原创:

plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'com.github.johnrengelman.shadow' version '5.2.0'
}
group 'com.smushytaco'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'https://papermc.io/repo/repository/maven-public/'
}
}
dependencies {
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '1.3.72'
//https://papermc.io/javadocs/paper/1.16/overview-summary.html
compileOnly group: 'com.destroystokyo.paper', name: 'paper-api', version: '1.16.1-R0.1-SNAPSHOT'
}
shadowJar {
getArchiveClassifier().set('')
project.configurations.implementation.canBeResolved = true
configurations = [project.configurations.implementation]
relocate 'kotlin', 'com.smushytaco.src.main.kotlin.com.smushytaco.plugin'
}
build.dependsOn shadowJar
Kotlin转换:
plugins {
java
kotlin("jvm") version("1.3.72")
id("com.github.johnrengelman.shadow") version("5.2.0")
}
group = "com.smushytaco"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/")
}
dependencies {
implementation("org.jetbrains.kotlin", "kotlin-stdlib", "1.3.72")
//https://papermc.io/javadocs/paper/1.16/overview-summary.html
compileOnly("com.destroystokyo.paper", "paper-api", "1.16.1-R0.1-SNAPSHOT")
}
tasks {
shadowJar {
archiveClassifier.set("")
project.configurations.implementation.get().isCanBeResolved = true
// Type Mismatch:
// Required: (Mutable)List<Configuration!>!
//Found: Array<NamedDomainObjectProvider<Configuration>>
configurations = [project.configurations.implementation]
relocate("kotlin", "com.smushytaco.src.main.kotlin.com.smushytaco.plugin")
}
build {
dependsOn(shadowJar)
}
}
我评论了Kotlin重写遇到的错误,为什么它与原始Groovy兼容,而不与该兼容?如何解决此错误?

最佳答案

用这个:

configurations = listOf(project.configurations.implementation.get())

关于kotlin - 如何解决此类型不匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63184940/

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