This might be a lazyweb question at this point, bu...
# multiplatform
z
This might be a lazyweb question at this point, but is it really not possible to run
main
functions from
jvmMain
sources in KMP projects? I’ve seen a bunch of past threads referring to both
compose.application.desktop.mainClass
and
kotlin.jvm.mainRun.mainClass
, but none of them ever seem to actually be resolved or support invocation from the IDE. This seems like a big missing piece for debugging if the only way to run with the necessary application classes bundled is via command line/`./gradlew run`
j
jvm().withJava() + application.mainClass working fine here
z
withJava()
is required?
j
For the application plugin, yes
z
as in the gradle
application
plugin?
j
Yep
Presumably I don't need either and can just click play on
main()
though?
z
brb need to remove all the android targets then for this to work
j
yeah i don't have Android
z
hmm, how are you applying the application plugin? Seems KMP generates conflicting tasks
Copy code
A problem occurred configuring root project 'field-spottr-root'.
> Cannot add task 'run' as a task with that name already exists.
z
¯\_(ツ)_/¯
still get the same issue re: it not bundling the whole classpath
Copy code
Exception in thread "main" java.lang.NoClassDefFoundError: androidx/collection/ScatterMapKt
	at androidx.compose.runtime.collection.ScopeMap.<init>(ScopeMap.kt:26)
	at androidx.compose.runtime.CompositionImpl.<init>(Composition.kt:479)
	at androidx.compose.runtime.CompositionImpl.<init>(Composition.kt:434)
	at androidx.compose.runtime.CompositionKt.Composition(Composition.kt:335)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Application.desktop.kt:219)
	...
e
In the IDE you should be able to just click the green play button without the
application
plugin. Is that what produces that stacktrace above?
Also I'm pretty sure if you set the
mainClass
(example here), the IDE adds a run configuration for it (but maybe that actually happens when I click the play button; I never actually checked that).
z
that is indeed what produces the stacktrace above
maybe it’s a specific issue with compose desktop
e
What version of CMP / AS / IDEA are you on? It works for me.
z
1.6.11, studio koala latest canary
Sadly IJ’s lagging Android support requires using studio
e
I'm on latest Jellyfish, but it's been working for a while, so I doubt that's it. You can try running the sample I linked above and see what happens with that.
j
I'm in IDEA 2024.2 EAP 3