Ray Rahke
03/15/2024, 10:29 AMplugins {
kotlin("jvm") version "1.9.23"
application
}
repositories {
mavenCentral()
}
application {
mainClass.set("MainKt")
}
sourceSets {
main {
kotlin.srcDirs("src/")
}
}
But then when I try changing jvm to multiplatform
plugins {
kotlin("multiplatform") version "1.9.23"
application
I get the following error
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/workspaces/testkotlin/build.gradle.kts' line: 13
* What went wrong:
Script compilation error:
Line 13: kotlin.srcDirs("src/")
^ Unresolved reference: srcDirs
Why does it differ here? it's as if the syntax for the gradle build file changes based on the plugin.Rob Elliot
03/15/2024, 10:31 AMRay Rahke
03/15/2024, 10:32 AMRay Rahke
03/15/2024, 10:32 AMRay Rahke
03/15/2024, 10:33 AMRay Rahke
03/15/2024, 10:34 AMRob Elliot
03/15/2024, 10:37 AMRay Rahke
03/15/2024, 10:37 AMRay Rahke
03/15/2024, 10:37 AMRob Elliot
03/15/2024, 10:41 AMVampire
03/15/2024, 10:45 AMVampire
03/15/2024, 10:49 AMkotlin {
jvm()
sourceSets {
jvmMain {
kotlin.srcDir("src")
}
}
}
Ray Rahke
03/15/2024, 10:57 AMplugins {
kotlin("multiplatform") version "1.9.23"
application
}
repositories {
mavenCentral()
}
application {
mainClass.set("MainKt")
}
kotlin {
jvm()
sourceSets {
jvmMain {
kotlin.srcDir("src")
}
}
}
but I am still getting an error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':run'.
> No main class specified and classpath is not an executable jar.
Ray Rahke
03/15/2024, 10:58 AM├── README.md
├── build.gradle.kts
├── settings.gradle.kts
└── src
└── main.kt
Ray Rahke
03/15/2024, 10:58 AMmain.kt
fun main() {
println("Hello")
}
Vampire
03/15/2024, 10:58 AMapplication
plugin and KMP plugin do not work together by default without further configurationRay Rahke
03/15/2024, 11:00 AMFAILURE: Build failed with an exception.
* What went wrong:
Task 'run' not found in root project 'testkotlin' and its subprojects.
Ray Rahke
03/15/2024, 11:01 AMplugins {
kotlin("multiplatform") version "1.9.23"
}
repositories {
mavenCentral()
}
kotlin {
jvm()
sourceSets {
jvmMain {
kotlin.srcDir("src")
}
}
}
Vampire
03/15/2024, 11:01 AMapplication
plugin adds the run
task. If you remvoe the, plugin, you also remove the taskRay Rahke
03/15/2024, 11:01 AMRay Rahke
03/15/2024, 11:05 AM./gradlew jsRun
FAILURE: Build failed with an exception.
* What went wrong:
Task 'jsRun' not found in root project 'testkotlin' and its subprojects. Some candidates are: 'jvmRun'.
Ray Rahke
03/15/2024, 11:05 AMplugins {
kotlin("multiplatform") version "1.9.23"
}
repositories {
mavenCentral()
}
kotlin {
js {
browser()
}
jvm()
js()
sourceSets {
jsMain {
kotlin.srcDir("src")
}
}
}
Vampire
03/15/2024, 11:06 AMjsRun
taskVampire
03/15/2024, 11:06 AM./gradlew tasks
Ray Rahke
03/15/2024, 11:07 AMRay Rahke
03/15/2024, 11:07 AMRay Rahke
03/15/2024, 11:07 AMRay Rahke
03/15/2024, 11:07 AMRay Rahke
03/15/2024, 11:07 AMThe Kotlin/JS plugin provides atask that lets you run pure Kotlin/JS projects without additional configuration.jsRun
Vampire
03/15/2024, 11:09 AMVampire
03/15/2024, 11:09 AMRay Rahke
03/15/2024, 11:09 AMVampire
03/15/2024, 11:09 AMRay Rahke
03/15/2024, 11:10 AMVampire
03/15/2024, 11:10 AMVampire
03/15/2024, 11:10 AMRay Rahke
03/15/2024, 11:10 AMRay Rahke
03/15/2024, 11:11 AMVampire
03/15/2024, 11:12 AMRay Rahke
03/15/2024, 11:12 AMVampire
03/15/2024, 11:13 AMRay Rahke
03/15/2024, 11:13 AMVampire
03/15/2024, 11:13 AMVampire
03/15/2024, 11:14 AMVampire
03/15/2024, 11:14 AMAdam S
03/15/2024, 11:14 AMVampire
03/15/2024, 11:15 AMVampire
03/15/2024, 11:15 AMRay Rahke
03/15/2024, 11:19 AM