https://kotlinlang.org logo
#ktor
Title
# ktor
j

jorge.rego

08/30/2020, 6:18 PM
Hi @zero_coding, would be nice if you can summarize your question in one single comment
☝️ 1
that will help reading the channel
😉
z

zero_coding

08/30/2020, 7:40 PM
Hi @jorge.rego I would like to run Ktor app on Jetty
and would like to know, how to do it.
I am using build.gradle.kts and would like to translate the following groovy code into kts:
Copy code
buildscript {
    ext.gretty_version = '2.0.0'
    repositories {
        jcenter()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.akhikhl.gretty:gretty:$gretty_version"
    }
}
apply plugin: 'kotlin'
apply plugin: 'war'
apply plugin: 'org.akhikhl.gretty'
webAppDirName = 'webapp'
gretty {
    contextPath = '/'
    logbackConfigFile = 'resources/logback.xml'
}
sourceSets {
    main.kotlin.srcDirs = [ 'src' ]
    main.resources.srcDirs = [ 'resources' ]
}
repositories {
    jcenter()
}
dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    compile "io.ktor:ktor-server-servlet:$ktor_version"
    compile "io.ktor:ktor-html-builder:$ktor_version"
    compile "ch.qos.logback:logback-classic:$logback_version"
}
kotlin.experimental.coroutines = 'enable'
task run
afterEvaluate {
    run.dependsOn(tasks.findByName("appRun"))
}
the question is how to do it.
j

Jorge R

08/30/2020, 9:13 PM
You are running Ktor as a Java app, so you would need to make a file that should contain a main Java method. Once you do that, IntelliJ will allow you to press play on the left of the method.
j

jorge.rego

08/30/2020, 9:29 PM
In case you just want to translate build.gradle to kts, here you can find a guide. But why dont just use a build.gradle file? https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/
z

zero_coding

08/30/2020, 10:05 PM
Thanks @jorge.rego a lot for your help