https://kotlinlang.org logo
#gradle
Title
# gradle
r

Richard Glen

11/09/2023, 12:56 AM
Hello, good day to all of you good people. Question: Is there a way to configure multiplatform gradle plugin's jvmRun task and set the main class (see error in forwarded message) Thanks a bunch!
v

Vampire

11/09/2023, 8:13 AM
Alternatively to the API you found, you could also set project property or system property
mainClass
, or
jvmRun.mainClass
.
r

Richard Glen

11/09/2023, 9:04 AM
Hi. Thanks for the reply, how do I do the first one? Can I set
mainClass
directly somewhere? I’m already doing the latter part (see my reply in the message I forwarded).
v

Vampire

11/09/2023, 9:05 AM
No, you are not
I said you can set these two as project property or system property, alternatively to the DSL you used
For example in
gradle.properties
, or via
-P
or
-D
and so on.
r

Richard Glen

11/09/2023, 9:09 AM
Ohh. That’s a nice info. A cool usecase would be to set main class differently. Would you kindly point a reference to this? Is this mentioned somewhere in the docs (the fact that you can set mainClass via project or system property)? May I know other options I can set in the system/project properties too?
v

Vampire

11/09/2023, 9:10 AM
I looked at the source code
💯 1
r

Richard Glen

11/09/2023, 9:13 AM
haha of course! I’ll get used to reading the source code someday. By source code, you mean the multiplatform plugin source code?
👌 1
c

CLOVIS

11/09/2023, 10:04 AM
Just add the
application
plugin: https://gitlab.com/opensavvy/notes/kotlin-fullstack/-/blob/main/app-cli/build.gradle.kts?ref_type=heads#L35 (notice the
jvm { withJava() }
, it's important for the application plugin to work)
r

Richard Glen

11/09/2023, 10:08 AM
Hi. Thanks for the reply. I didn't want to add the application plugin. I'm wondering for its need to be added because It seems multiplatform plugin already has a jvmRun task.
c

CLOVIS

11/09/2023, 2:04 PM
Is it new? I don't remember using it. I can't find any documentation about it other than the original issue (but there's no explanation of how it's supposed to be used)
v

Vampire

11/09/2023, 2:15 PM
Yes, new in 1.9.20
🙌 1
Commit e0389a0a870766b3d595b93c24905b491d02fab9
c

CLOVIS

11/09/2023, 2:40 PM
Well, that test answers your question; the configuration is
Copy code
kotlin {
    jvm {
        mainRun {
            mainClass.set("…")
        }
    }
}
v

Vampire

11/09/2023, 2:41 PM
Yes, he found out already within his mentioned thread in #multiplatform in the original post here. And alternatively you can use the two properties I mentioned and both either as system property or project property.
r

Richard Glen

11/10/2023, 7:47 AM
Thanks a lot for accommodating! Kotlin is awesome!