Where to put gradle dependencies block in kotlin native project generated by Intellij IDEA?

时光毁灭记忆、已成空白 提交于 2020-05-15 22:44:56

问题


I'm trying to make my first app in Kotlin Native. I want to add TornadoFX to my freshly created project. I need to add a dependency according to TornadoFX guide

dependencies {
    compile 'no.tornado:tornadofx:x.y.z'
}

The issue is - I cant figure out where exactly do I put it.

This is my build.gradle contents (generated by IntelliJ IDEA):

plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.60'
}
repositories {
    mavenCentral()
}
kotlin {
    // For ARM, should be changed to iosArm32 or iosArm64
    // For Linux, should be changed to e.g. linuxX64
    // For MacOS, should be changed to e.g. macosX64
    // For Windows, should be changed to e.g. mingwX64
    mingwX64("mingw") {
        binaries {
            executable {
                // Change to specify fully qualified name of your application's entry point:
               entryPoint = 'sample.main'
                // Specify command-line arguments, if necessary:
                runTask?.args('')
            }
        }
    }
    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 {
        }
    }
}

// Use the following Gradle tasks to run your application:
// :runReleaseExecutableMingw - without debug symbols
// :runDebugExecutableMingw - with debug symbols

Places I tried:

1. top level

> Could not find method compile() for arguments [no.tornado:tornadofx:1.7.19] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

2. inside kotlin {}

> Could not find method compile() for arguments [no.tornado:tornadofx:1.7.19] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

3. inside mingwMain{}

> Could not find method compile() for arguments [no.tornado:tornadofx:1.7.19] on object of type org.jetbrains.kotlin.gradle.plugin.mpp.DefaultKotlinDependencyHandler.

Also, when put inside mingwMain, the compile line gets highlighted with a notice 'compile' cannot be applied to '(java.lang.String)'


回答1:


For the Kotlin multiplatform plugin, the dependency block should go into each source set. However, there is no type called compile. Rather, you can use implementation or one of the other types which you can read about in the documentation.

Example:

sourceSets {
    mingwMain {
        dependencies {
            implementation 'no.tornado:tornadofx:x.y.z'
        }
    }
}

BTW, why are you using the Groovy DSL and not the Kotlin DSL if you are writing a Kotlin project? :-)




回答2:


As it was pointed out by this comment we cannot use TornadoFX in Kotlin Native, so I was doing everything wrong since the beginning, and this is not really a gradle issue.



来源:https://stackoverflow.com/questions/59198442/where-to-put-gradle-dependencies-block-in-kotlin-native-project-generated-by-int

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!