Hello, I have a problem with JVM Multiplatform and...
# gradle
j
Hello, I have a problem with JVM Multiplatform and Application plugins, I can not run my main
Copy code
plugins {
    kotlin("multiplatform")
    application
}

application {
    mainClass.set("io.github.jervnorsk.aden.server.Main")
}

kotlin {
    jvm {
        testRuns["test"].executionTask.configure {
            useJUnitPlatform()
            testLogging {
                events = setOf(
                    org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED,
                    org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
                )
                exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL

                showExceptions = true
                showStandardStreams = true
            }
        }

    }
    sourceSets {
        val commonMain by getting {
            dependencies {}
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val jvmMain by getting {
            dependencies {
                implementation("io.ktor:ktor-server-core:${extra["ktor.version"]}")
                implementation("io.ktor:ktor-server-netty:${extra["ktor.version"]}")
                implementation("ch.qos.logback:logback-classic:1.2.5")
            }
        }
    }
}
I add my repository view
Copy code
> Task :run FAILED
Error: Could not find or load main class io.github.jervnorsk.aden.server.Main
Caused by: java.lang.ClassNotFoundException: io.github.jervnorsk.aden.server.Main

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/home/jervnorsk/.sdkman/candidates/java/11.0.12-open/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at <https://help.gradle.org>

BUILD FAILED in 2s
1 actionable task: 1 executed
v
What's the content of
main.kt
?
Or look in the compiled classes folder which classes you have available
j
The
main.kt
content is:
Copy code
@file:JvmName("Main")

package io.github.jervnorsk.aden.server

fun main(args: Array<String>) {
    println("Hello World!")
}
message has been deleted
v
Well, it seems the KMP Gradle plugin does not (yet) integrate with the
application
plugin and you need to connect them yourself
j
Thank you!
t
You need to add
withJava()
into your
jvm
target. Check this issue
K 1
j
Thank you, it works!
v
Ah, good to know, thanks
j
withJava() doesn't work for me because I am also using android(). I get this error: The 'java' plugin has been applied, but it is not compatible with the Android plugins.
Copy code
kotlin {
    android()
    jvm {
      withJava()
    }
280 Views