Philip Dukhov
11/18/2020, 10:24 PMError: Could not find or load main class com.well.server.ApplicationKt
I’ve found a solution to run it, using following task:
task<JavaExec>("run") {
main = "com.well.server.ApplicationKt"
val jvm by kotlin.targets.getting
val main: KotlinCompilation<KotlinCommonOptions> by jvm.compilations
val runtimeDependencies = (main as KotlinCompilationToRunnableFiles<KotlinCommonOptions>).runtimeDependencyFiles
classpath = files(main.output.allOutputs, runtimeDependencies)
}
One of the minuses - I can’t debug server and run an other module, because server starts running as part of task, and task progress remains 92 until I abort it.
Is there a better solution?
But the main goal right now is to deploy the server. Following the official guide, I tried this code:
tasks.create("stage") {
dependsOn(tasks.getByName("installDist"))
}
application {
mainClassName = "ApplicationKt"
}
distributions {
main {
contents {
from("$buildDir/libs") {
rename("${rootProject.name}-jvm", rootProject.name)
into("lib")
}
}
}
}
tasks.getByName<JavaExec>("run") {
`classpath(tasks.getByName<Jar>("jvmJar")) // so that the JS artifacts generated by jvmJar
can be found and served`
}
But ./gradlew :server:run
returns Could not find or load main class ApplicationKt
error, and :server:jvmJar
finishes without errors but doesn’t seems to produce the outputBig Chungus
11/19/2020, 9:30 AMPhilip Dukhov
11/19/2020, 2:09 PMBig Chungus
11/19/2020, 2:12 PMsrc/jvmMain/resources
?Philip Dukhov
11/19/2020, 2:29 PMBig Chungus
11/19/2020, 2:31 PMbuild.gradle.kts
add withJava()
in kotlin { jvm {} }
./gradlew run
and play buttonPhilip Dukhov
11/19/2020, 2:43 PMBig Chungus
11/19/2020, 2:44 PM./gradlew run
working by adding
application {
mainClassName = "io.ktor.server.netty.EngineMain"
}
to gradlefilePhilip Dukhov
11/19/2020, 3:15 PMio.ktor.server.netty.EngineMain
in the config, and it says Neither port nor sslPort specified
. yet running ./gradlew run
indeed worksBig Chungus
11/19/2020, 3:32 PM//include(":app")
in settings.gradle.kts
Philip Dukhov
11/19/2020, 3:51 PMBig Chungus
11/19/2020, 3:55 PMPhilip Dukhov
11/19/2020, 3:59 PMBig Chungus
11/19/2020, 4:07 PMPhilip Dukhov
11/19/2020, 4:23 PMapp
? I just tried on your commit and it works only with the committed app
module.Big Chungus
11/19/2020, 4:45 PMandylamax
11/19/2020, 4:46 PMBig Chungus
11/19/2020, 4:47 PMandylamax
11/19/2020, 4:50 PMplugins {
kotlin("multiplatform")
id("tz.co.asoft.application") version "0.0.7"
}
konfig {
debug(
"Main-Class" to "io.ktor.server.netty.EngineMain"
)
}
after that you can just run ./gradlew jvmRunDebug
Philip Dukhov
11/19/2020, 5:33 PMCould not find or load main class
if android module is enabled, and works if disabled.. also even if it works(without android module), running executable created with :distZip
fails with Neither port nor sslPort specified
.. tried specifying port as a param, it says No configuration setting found for key 'ktor'
Why can it ignore application.conf
?andylamax
11/19/2020, 6:06 PMBig Chungus
11/19/2020, 6:33 PMPhilip Dukhov
11/20/2020, 8:11 AM:distZip
fails with Neither port nor sslPort specified
.. tried specifying port as a param, it says No configuration setting found for key 'ktor'
Why can it ignore application.conf
?Big Chungus
11/20/2020, 8:55 AMPhilip Dukhov
11/20/2020, 11:27 AMBig Chungus
11/20/2020, 1:52 PM