Hi All, I'm trying to configure a server to use `...
# ktor
s
Hi All, I'm trying to configure a server to use
build.gradle.kts
instead of
build.gradle
. When I configure it from the wizard and build it works fine out of the box. When I convert the file I get the following error.
Copy code
INFO  Application - No ktor.deployment.watch patterns specified, automatic reload is not active
Exception in thread "DefaultDispatcher-worker-3" java.lang.ClassNotFoundException: Module function cannot be found for the fully qualified name 'com.example.ApplicationKt.module'
This is my
build.gradle.kts
file
Copy code
buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven{
            url = uri("<https://kotlin.bintray.com/ktor>")
            url = uri("<https://kotlin.bintray.com/kotlinx>")
        }
    }
    
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
    }
}

//Setup the application plugins
plugins {
    application
    kotlin("jvm") version "1.3.72"
}

group = "com.example"
version = "0.0.1"

application {
    mainClassName = "io.ktor.server.cio.EngineMain"
}

sourceSets["main"].resources.srcDirs("resources")
sourceSets["test"].resources.srcDirs("testresources")

repositories {
    mavenCentral()
    mavenLocal()
    jcenter()
    maven{
        url = uri("<https://kotlin.bintray.com/ktor>")
        url = uri("<https://kotlin.bintray.com/kotlinx>")
    }
}

dependencies {
    implementation(kotlin("stdlib-jdk8"))
    implementation("io.ktor:ktor-server-cio:1.3.2")
    implementation("ch.qos.logback:logback-classic:1.2.1")
    implementation("io.ktor:ktor-server-core:1.3.2")
    implementation("io.ktor:ktor-locations:1.3.2")
    implementation("io.ktor:ktor-metrics:1.3.2")
    implementation("io.ktor:ktor-client-core:1.3.2")
    implementation("io.ktor:ktor-client-core-jvm:1.3.2")
    implementation("io.ktor:ktor-client-cio:1.3.2")
    implementation("io.ktor:ktor-client-json-jvm:1.3.2")
    implementation("io.ktor:ktor-client-gson:1.3.2")
    implementation("io.ktor:ktor-client-logging-jvm:1.3.2")
    testImplementation("io.ktor:ktor-server-tests:1.3.2")
}
Im not really sure why its not picking it up.
This is my
application.conf
Copy code
ktor {
    deployment {
        port = 8080
        port = ${?PORT}
    }
    application {
        modules = [ com.example.ApplicationKt.module ]
    }
}
Solved! I was missing the Kotlin Source sets. Seems it needs them post conversion.
Copy code
kotlin.sourceSets["main"].kotlin.srcDirs("src")
kotlin.sourceSets["test"].kotlin.srcDirs("test")