Joseph Magara
07/14/2021, 8:51 PMError: Could not find or load main class io.ktor.server.netty.EngineMain
Does anyone know how to fix it?buildscript {
repositories {
jcenter()
mavenCentral()
google()
maven { url "<https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven>" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
}
}
apply plugin: 'kotlin'
apply plugin: 'application'
apply plugin: 'kotlin-kapt'
apply plugin: 'java'
apply plugin: 'org.jetbrains.kotlin.jvm'
group 'com.example'
version '0.0.1'
mainClassName = "io.ktor.server.netty.EngineMain"
jar {
manifest {
attributes 'Main-Class': mainClassName
}
}
sourceSets {
main.kotlin.srcDirs = main.java.srcDirs = ['src']
test.kotlin.srcDirs = test.java.srcDirs = ['test']
main.resources.srcDirs = ['resources']
test.resources.srcDirs = ['resources']
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven { url '<https://kotlin.bintray.com/ktor>' }
maven { url "<https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven>" }
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}
test {
useJUnitPlatform()
}
dependencies {
...
}
rnett
07/14/2021, 9:44 PMJoseph Magara
07/15/2021, 2:50 AMjengelman
fatjar gradle plugin and it solved my issue.jengelman
fatjar gradle plugin to your gradle file (and remove the jar
closure if you had one in your gradle file) and it should resolve the issue for you. It will create a fatjar that will contain your app and it’s dependencies. This resolves the issue.