Gradle可以为一个操作系统生成多个Kotlin本机二进制文件吗?

时间:2018-12-28 20:40:29

标签: gradle kotlin kotlin-native

我可以说服Gradle生成多个二进制文件吗?我有几个Kotlin软件包,其文件带有正确的“ fun main(...)”,但是默认的IntelliJ build.gradle文件仅允许我指定一个“ compilations.main.entryPoint”。 如果可以的话,可以将主要功能放入Kotlin类或对象中。

将entryPoint参数更改为数组不起作用:)

如果目前无法实现,这是Gradle的一般限制还是仅是“ kotlin-multiplatform”插件的限制?

plugins {
    id 'kotlin-multiplatform' version '1.3.11'
}

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 = 'hello.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 = 'debug' // '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 ''
        }
    }
}

1 个答案:

答案 0 :(得分:2)

https://github.com/JetBrains/kotlin-native/issues/2505中,我得到的答案是Kotlin Native 1.3.20可以实现!