Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate Kotlinx coroutines in intelliJ project

I‘m using intellij for a while now. There I work on a javaFx project, which is mainly written in java but I discovered Kotlin to be a nice alternative.

Recently I read about coroutines in Kotlin and I just can‘t figure out how to add the Kotlinx library to my project. I can only find the snippets for maven and gradle. But I‘m a complete nobby at this and I don‘t use one of this (At least I think so). So how can I add the kotlinx stuff to my project???

Kotlinx: KotlinX coroutines

Project structure: enter image description here

like image 297
Punika Avatar asked Feb 28 '18 17:02

Punika


People also ask

How do I add Coroutines to Kotlin project?

Go to Tools → Kotlin → Configure Kotlin Plugin Updates, select “Stable” in the Update channel drop-down list, and then click Check for updates. We are adding coroutines-core along with coroutines-android. Now, sync your project with gradle files and you are ready use the latest Coroutines.

How are Coroutines implemented?

We can add the Goroutine to the Go program by adding the keyword go in front of the function execution. Once we add the go keyword in front of the self-executing function, we are adding concurrency to the execution. Let's see the impact of adding the go keyword to the above execution.


1 Answers

In the Project Structure dialog, go to Project Settings | Libraries, press "+" button and select "From Maven..." in the popup. In the dialog that appears, enter the name and version of the library you need, which you can find out in the documentation. (For the current version of the core library of kotlinx.coroutines, enter org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2). Then select the modules to which the library will be added.

like image 164
yole Avatar answered Sep 20 '22 01:09

yole