I'm trying to add `.jar` dependencies to my multip...
# multiplatform
o
I'm trying to add
.jar
dependencies to my multiplatform project without luck so far. In a regular Gradle project for Jvm, everything is fine, adding the
fileTree
to my
dependencies
section works. In a multiplatform Gradle project (using
.gradle.kts
) in the
jvmMain
section, Gradle syncs properly, the content listed by the
fileTree
is correct (checked thanks to printed
fileTree(...).files
) but nothing resolves in the IDE completion after. If I manually tweak the module dependencies in the IntelliJ UI (thus editing the under the hood
.iml
project definition), I get access to the expected types in my
*.jar
but it fails at runtime (I guess it's normal, the launch is using Gradle I assume). If I tweak the runtime classpath in
Copy code
tasks.named<JavaExec>("run")
and launch in command line, it works. I also tried adding the
fileTree
dependency to the
kotlin.jvm.dependencies
section without more success. So, I'm wondering why the
dependencies
section of
jvmMain
ignores the jar files provided as
implementation
.
Copy code
kotlin {
    jvm {
        jvmToolchain(17)
        withJava()
...
    }
    sourceSets {
...
        val jvmMain by getting {
            dependencies {
...
                implementation(fileTree(mapOf("dir" to file("../dir_with_my_jars"), "include" to listOf("*.jar"))))
            }
        }
    }
}
Gradle : 7.6.1
Copy code
plugins {
    kotlin("multiplatform") version "1.8.21"
    application
}
What works in a regular Jvm gradle module:
Copy code
plugins {
    kotlin("jvm")
}

dependencies {
    implementation(fileTree(mapOf("dir" to file("../dir_with_my_jars"), "include" to listOf("*.jar"))))
}
h
did you find a solution on non-jvm gradle modules?
o
nop 😞
😢 1
110 Views