如何将java库添加到kotlin native

fun*_*uit 2 java kotlin kotlin-native

所以我尝试使用intellij创建kotlin/native应用程序(我在项目创建中选择了模板kotlin-> kotlin/native).它创建了示例gradle hello world项目.下载后所有依赖项编译成exe文件并正常运行.但现在我需要包含som库,我无法弄清楚如何.首先,我只想包含任何jar库(例如jackson-core).这就是build.gradle文件的样子:

plugins {
    id 'kotlin-multiplatform' version '1.3.0'
}
repositories {
    mavenCentral()
}

kotlin {
    targets {
        // For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64
        // For Linux, preset should be changed to e.g. presets.linuxX64
        // For MacOS, preset should be changed to e.g. presets.macosX64
        fromPreset(presets.mingwX64, 'mingw')

        configure([mingw]) {
            // Comment to generate Kotlin/Native library (KLIB) instead of executable file:
            compilations.main.outputKinds('EXECUTABLE')
            // Change to specify fully qualified name of your application's entry point:
            compilations.main.entryPoint = 'sample.main'
        }
    }
    sourceSets {
        // Note: To enable common source sets please comment out 'kotlin.import.noCommonSourceSets' property
        // in gradle.properties file and re-import your project in IDE.

        mingwMain {
        }
        mingwTest {
        }
    }
}


task runProgram {
    def buildType = 'release' // Change to 'debug' to run application with debug symbols.
    dependsOn "link${buildType.capitalize()}ExecutableMingw"
    doLast {
        def programFile = kotlin.targets.mingw.compilations.main.getBinary('EXECUTABLE', buildType)
        exec {
            executable programFile
            args ''
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我试着补充一下

dependencies {
    implementation fileTree(dir: 'lib', include: ['*.jar'])
}
Run Code Online (Sandbox Code Playgroud)

dependencies {
    compile fileTree(dir: 'lib', include: ['*.jar'])
}
Run Code Online (Sandbox Code Playgroud)

在每个部分,它没有帮助.我仍然无法从jackson包中导入任何东西,并且它没有出现在"外部库"部分的想法中.我也尝试指定lib的全名并使用其他东西而不是实现或编译 - 仍然没有结果.我在这里错过了什么?

yol*_*ole 9

Kotlin/Native不支持Java库.您需要使用多平台库(kotlinx.serialization)或本机库(如libjson).