I have a multiplatform project where in one of the...
# gradle
l
I have a multiplatform project where in one of the modules I use some features that need an
--add-opens
argument. As such, I have a few questions about this: • How can I add this JVM argument to the tests in this module? • Is there a way to get the module to add this parameter to some global list of arguments so all other modules that depend on this one doesn't have to explicitly add this argument to their JVM arguments?
e
1.
Copy code
tasks.test {
    jvmArgs(listOf("--add-opens", "..."))
}
2. you can try adding to
JAVA_TOOL_OPTIONS
outside of Gradle which will apply to all Java launches, but there's no configuration for forwarding JVM args to dependent modules
l
Thanks
Let me try
Hmm,
could not find method test()
. Where do I actually put this? This is the module in question by the way: https://codeberg.org/loke/array/src/branch/master/contrib/arrow/build.gradle
Ah wait. Not
.test
but rather
.jvmTest
it seems.
v
Yeah, KMP is different 😄
l
Also,
listOf
doesn't work. I needed to use
+= "..."
. I guess
listOf
would be for the Kotlin syntax.
e
if it's Groovy DSL and not Kotlin there's other changes too
l
Is there a way to disable all the
--add-opens
nonsense in the JVM and get it to work like old Java used to work?
e
nope
l
So in my case, where I have a set of jar files that users can add to get extra functionality, I can't just have the users drop the jar files in a modules directory, but I also need them to add a parameter on the commandline. Surely I'm missing something here.
v
Sure, use old JVM 🙂
Btw. iirc it would be more like
Copy code
kotlin {
    jvm {
        testRuns.configureEach {
            executionTask {
                jvmArgs(...)
            }
        }
    }
idiomaticly
e
well if it's another module I think you could use module-info.java. but JPMS doesn't play well with KMP afaik, and that doesn't let you open Java internals
l
I see. Thanks.
I need to read up on the module stuff. I've avoided it for a long time.