gradle - Gradle 能否生成多个 Kotlin Native 二进制文件(针对一个操作系统)?

标签 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 ''
        }
    }
}

最佳答案

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

关于gradle - Gradle 能否生成多个 Kotlin Native 二进制文件(针对一个操作系统)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53964059/

相关文章:

gradle - 如何使用bmuschko/gradle-docker-plugin通过Gradle自动将文件复制到IBM Containers中正在运行的docker

android - 错误:(72)检索项目的父项时出错:未找到与给定名称 'TextAppearance.AppCompat.Display1'匹配的资源

constructor - Kotlin 在声明之前初始化变量?

android - Jetpack 用点圆组成画弧

kotlin - Kotlin Cinterops native 库名称

multithreading - 在 Kotlin Native 中,如何将对象保存在单独的线程中,并在不使用 C 指针的情况下从任何其他线程中改变其状态?

kotlin - 如何将 Kotlin ByteArray 转换为 NsData,反之亦然

android - 为 Gradle 和 Cordova 5 指定签名配置

file-io - 在 Kotlin 中使用 BiPredicate 的 Files.find()

spring-boot - 如何使用Spring Boot从另一个文件夹加载静态资源