我是新来的科特林,所以我很抱歉,提前,如果这是一个简单的错误。
目前,我正在尝试将api (用Kotlin编写)重写为java 17。到目前为止,一切都正常。但现在我收到了一些不受欢迎的信息:
不建议使用'toLowerCase():String‘。使用小写()代替.
当然,我知道这意味着什么,所以我试着在下面的图片中这样做:https://i.stack.imgur.com/vT8k5.png
但是为什么它找不到小写函数呢?
这是在我的build.gradle中:
plugins {
id 'org.jetbrains.kotlin.jvm'
id "org.jetbrains.kotlin.kapt"
id "org.jetbrains.dokka"
id "java-library"
id "maven-publish"
id "jacoco"
id "io.gitlab.arturbosch.detekt"
id "org.jlleitschuh.gradle.ktlint"
id "com.github.gmazzo.buildconfig"
}
apply from: "${rootDir}/gradle/dependencies.gradle"
tasks.withType(org.jetbrains.dokka.gradle.DokkaTask).configureEach {
dokkaSourceSets {
configureEach {
sourceLink {
localDirectory.set(file("src/main/kotlin"))
remoteUrl.set(uri("").toURL())
}
externalDocumentationLink { url.set(new URL("https://square.github.io/retrofit/2.x/retrofit/")) }
externalDocumentationLink { url.set(new URL("https://square.github.io/okhttp/3.x/okhttp/")) }
externalDocumentationLink { url.set(new URL("https://square.github.io/moshi/1.x/moshi/")) }
}
}
}
tasks.dokkaJavadoc.configure {
outputDirectory.set(javadoc.destinationDir)
}
task sourceJar(type: Jar) {
archiveClassifier = "sources"
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
archiveClassifier = "javadoc"
from javadoc.destinationDir
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "17"
allWarningsAsErrors = true
freeCompilerArgs = ["-Xjsr305=strict", "-progressive"]
}
}
kapt {
useBuildCache = true
}
test {
finalizedBy jacocoTestReport
useJUnitPlatform()
}
buildConfig {
packageName("my.package") // forces the package. Defaults to '${project.group}'
useKotlinOutput() // adds `internal` modifier to all declarations
buildConfigField("String", "packageName", "\"my.package\"")
buildConfigField("String", "version", provider { "\"${project.version}\"" })
}
jacoco {
setToolVersion(jacocoVersion)
}
jacocoTestReport {
reports {
xml.required = true
html.required = false
}
}
ktlint {
disabledRules = ["import-ordering"]
version = ktlintVersion
reporters {
reporter "checkstyle"
}
}
detekt {
version = detektVersion
buildUponDefaultConfig = true
config = files("$rootDir/config/detekt.yml")
}
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
compileKotlin {
kotlinOptions {
jvmTarget = "17"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "17"
}
}
发布于 2022-01-29 18:58:11
确保您的kotlin-stdlib
版本是1.5或更高。检查这
https://stackoverflow.com/questions/70908263
复制相似问题