admin管理员组文章数量:1355675
I am using IntelliJ IDEA Community Edition 2023.3.2. I tried to do the following:
val fullName = "Donn Felker"
println(fullName::class)
The output I got is:
class java.long.String (Kotlin reflection is not available)
According to Kotlin reflection is not available I need to add the following to the build.gradle
:
compile ".jetbrains.kotlin:kotlin-reflect:$kotlin_version"
I can see the build.gradle.kts
, but I don't know how to add a value in the file:
plugins {
kotlin("jvm") version "1.9.21"
}
group = ".example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(".jetbrains.kotlin:kotlin-test")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(21)
}
I am using IntelliJ IDEA Community Edition 2023.3.2. I tried to do the following:
val fullName = "Donn Felker"
println(fullName::class)
The output I got is:
class java.long.String (Kotlin reflection is not available)
According to Kotlin reflection is not available I need to add the following to the build.gradle
:
compile ".jetbrains.kotlin:kotlin-reflect:$kotlin_version"
I can see the build.gradle.kts
, but I don't know how to add a value in the file:
plugins {
kotlin("jvm") version "1.9.21"
}
group = ".example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(".jetbrains.kotlin:kotlin-test")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(21)
}
Share
Improve this question
edited Mar 29 at 17:43
jonrsharpe
122k30 gold badges268 silver badges475 bronze badges
asked Mar 29 at 17:19
smalltownstorysmalltownstory
73 bronze badges
1
- docs.gradle./current/userguide/… – jonrsharpe Commented Mar 29 at 17:44
1 Answer
Reset to default 0You can add the value into the `dependencies` section. For Kotlin DSL, you can do this:
dependencies {
testImplementation(".jetbrains.kotlin:kotlin-test")
implementation (libs.kotlin.reflect) // Add this to your file.
}
Don't fet to Sync Gradle after updating build.gradle.kts
本文标签: kotlinHow to add value to buildgradlektsStack Overflow
版权声明:本文标题:kotlin - How to add value to build.gradle.kts? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744009662a2575330.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论