I
I
iris_wolf2020-07-15 21:12:07
IntelliJ IDEA
iris_wolf, 2020-07-15 21:12:07

How to install kotlin library?

I want to use ktor in my project.
But I don’t know how to install this library for my project.
I saw some maven / gradle options, but I didn’t find a normal explanation for a beginner.
ktor:
https://www.codeflow.site/en/article/kotlin-khttp
https://ktor.io/

Here is the project root
DLGGS5z.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jershell, 2020-07-15
@nzlgd

1. Translate the project to gradle. To do this, first we put this same gradle, then we create a folder, go there in the console and write
gradle init
There will be something like this.

Starting a Gradle Daemon (subsequent builds will be faster)

Select type of project to generate:
  1: basic
  2: application
  3: library
  4: Gradle plugin
Enter selection (default: basic) [1..4] 2

Select implementation language:
  1: C++
  2: Groovy
  3: Java
  4: Kotlin
  5: Swift
Enter selection (default: Java) [1..5] 4

Select build script DSL:
  1: Groovy
  2: Kotlin
Enter selection (default: Kotlin) [1..2] 2

Project name (default: rm_me): moy_proekt

This will generate a default gradle project for kotlin
2. Next, we can include any dependencies we want. To do this, in the generated project, open the build.gradle.kts file and add to the dependencies section
dependencies {
  implementation("io.ktor:ktor-server-netty:1.3.2")
}

here in more detail, but gradle syntax is used, not kts https://ktor.io/quickstart/quickstart/gradle.html
and almost everything is the
same, but a little more details here In general, the goal itself is to transfer the project to gradle first, since Kotlin has almost all dependencies through it and are connected.

A
alekseyHunter, 2020-07-22
@alekseyHunter

Use Android Studio, if you write a mobile phone, Gradle is added to the project out of the box.
Next, add the library to buide.gradle:
implementation("название библиотеки:версия)
For HTTP, Retrofit2 is better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question