So, I'm rewriting some of my projects from Java to Kotlin, because I'm overall more comfortable with the language and I stumbled upon a little problem with my IDE (InteliJ IDEA Ultimate).
I published one of my libraries to public repo on GitHub and used it as an dependency in other project using Gradle and JitPack , it downloads and is included in "External Libraries" .
However I'm unable to use any of it in my .kt files. (IDE shows "Unresolved Reference" error.) https://i.stack.imgur.com/qFDWN.png
This does not happen, when I'm trying to do the same thing in Java. (Same project) https://i.stack.imgur.com/NV22F.png
build.gradle.kts
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = uri("https://papermc.io/repo/repository/maven-public/")
}
maven {
name = "jitpack"
url = uri("https://www.jitpack.io")
}
}
dependencies {
testImplementation(kotlin("test-junit"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compileOnly("com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT")
implementation("com.github.ThePlay3r:PLJRApi-Spigot:563362408c")
}
It's quite frustrating as I was really excited about Kotlin, but this makes me unable to do much. Does anyone have any idea how to fix this, or any alternative for adding libraries to my project?
Apparently, it's an known issue, that was reported and is tracked here: https://youtrack.jetbrains.com/issue/KT-25709 .
My current, temporary fix is excluding some of the kotlin's files in the shadowJar
task.
tasks.named<ShadowJar>("shadowJar") {
exclude("**/*.kotlin_metadata")
exclude("**/*.kotlin_module")
exclude("**/*.kotlin_builtins")
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.