Добавить поддержку нескольких платформ в проект Kotlin - PullRequest
0 голосов
/ 29 мая 2020

Я пытаюсь перенести проект jvm Kotlin на мультиплатформенный, чтобы я мог скомпилировать собственные двоичные файлы для разных платформ (macOs, Win и Linux).

Здесь репозиторий проекта: https://github.com/davioooh/leanpub-manuscript-tools

Я новичок в Kotlin многоплатформенных функциях и не могу понять, как правильно перенести структуру проекта и зависимости.

Я пытаюсь настроить gradle.build.kts таким образом:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("multiplatform").version("1.3.72")
}

group = "com.davioooh.lptools"
version = "0.1.0-SNAPSHOT"
description = "leanpub-manuscript-tools"

repositories {
    mavenCentral()
}

kotlin {
    /* Targets configuration omitted.
    *  To find out how to configure the targets, please follow the link:
    *  https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-targets */

    val junitVersion = "5.6.2"
    val assertjVersion = "3.16.1"
    val cliktVersion = "2.7.1"

    sourceSets {
        commonMain {
            dependencies {
                implementation(kotlin("stdlib-common"))
                implementation("com.github.ajalt:clikt-multiplatform:$cliktVersion")
            }
        }
        commonTest {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }

        // Default source set for JVM-specific sources and dependencies:
        jvm().compilations["main"].defaultSourceSet {
            dependencies {
                implementation(kotlin("stdlib"))
            }
        }
        // JVM-specific tests and their dependencies:
        jvm().compilations["test"].defaultSourceSet {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
                implementation("org.assertj:assertj-core:$assertjVersion")
                runtimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
            }

            tasks.withType<KotlinCompile>().configureEach {
                kotlinOptions {
                    jvmTarget = "1.8"
                }
            }

            tasks.withType<Test>().configureEach {
                useJUnitPlatform()
            }
        }

        mingwX64("native") {
            binaries {
                executable()
            }
        }
    }
}

tasks.withType<Wrapper> {
    gradleVersion = "6.3"
    distributionType = Wrapper.DistributionType.ALL
}

но я получаю Unresolved reference ошибки gradlew nativeBinaries.

Это оригинал gradle.build.kts

Не могли бы вы мне помочь?

Ссылка

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...