I am using a recently created project via korge plugin, I tested as well using the Project Template with same results.
After creating the project, add a dependency to korge using dependencyMulti (or dependency specifying commonMainApi). Use that dependency on code, like main.kt file. When running the project via ./gradle runJvm, the project compiles without issues, however the IDE, Intellij does not recognize the dependency added to provide code completion on other useful features. Intellij show error for the dependency files.
As example I am using jackson library, but just to demonstrate the issue. I have seen the same issue with other dependencies.
build.gradle.kts
...
apply<KorgeGradlePlugin>()
korge {
...
dependencyMulti("com.fasterxml.jackson.module:jackson-module-kotlin:2.11.0")
dependencyMulti("com.fasterxml.jackson.core:jackson-databind:2.11.0")
// To selectively enable targets
targetJvm()
...
}
main,kt
...
import com.fasterxml.jackson.databind.ObjectMapper
suspend fun main() = Korge(width = 512, height = 512, bgcolor = Colors["#2b2b2b"]) {
val mapper = ObjectMapper()
println("Using external dependency, result=${mapper.writeValueAsString("testValue")}")
val minDegrees = (-16).degrees
...
As reference: I was checking korge-samples repository. Intellij works fine for korlibs.luak dependency.
Additional note: result of conversation about this issue on Discord channel
I have received feedback via discord. I got a suggestion to try the following changes. However I was not able to make it work. At the same time this structure is completely different on how the project template is organized, doesn't seem a proper solution in the long run.
Suggested build.gradle.kts content via discord.
plugins {
id("com.soywiz.korge")
}
korge {
targetJvm()
targetJs()
}
val kotestVersion: String by project
val reflectionsVersion: String by project
kotlin {
sourceSets {
all {
languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn")
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
}
getByName("jvmTest") {
dependencies {
implementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
implementation("org.reflections:reflections:$reflectionsVersion")
}
}
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
And the following settings.gradle.kts:
pluginManagement {
repositories {
mavenLocal()
maven("https://dl.bintray.com/korlibs/korlibs")
maven("https://plugins.gradle.org/m2/")
mavenCentral()
google()
maven("https://dl.bintray.com/kotlin/kotlin-dev")
maven("https://dl.bintray.com/kotlin/kotlin-eap")
}
plugins {
id("com.soywiz.korge") version "2.0.0.2"
}
}
rootProject.name = "project"
check