简体   繁体   中英

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

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)'

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? :-)

如此评论所指出的,我们不能在 Kotlin Native 中使用 TornadoFX,所以从一开始我就做错了所有事情,这并不是一个真正的 gradle 问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM