4

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

davis
  • 1,137
  • 1
  • 10
  • 28
  • 2
    Hello! You cannot use TornadoFX in the Native project, please have a look at [this](https://github.com/edvin/tornadofx/issues/1116) issue in it's GH. This framework can be used only when you're targeting the JVM. To find applicable libraries, check [here](https://www.jetbrains.com/lp/mobilecrossplatform/) and [here](https://github.com/AAkira/Kotlin-Multiplatform-Libraries). – Artyom Degtyarev Dec 06 '19 at 07:53

2 Answers2

2

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

Bjørn Vester
  • 6,851
  • 1
  • 20
  • 20
1

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.

davis
  • 1,137
  • 1
  • 10
  • 28