in a multiplatform project gradle build (kotlin ds...
# multiplatform
c
in a multiplatform project gradle build (kotlin dsl) how can i create a JavaExec task that has the jvmTest classpath? in the jvm only build it was just
classpath = sourceSets["test"].runtimeClasspath
e
configurations["jvmTestRuntimeClasspath"]
should be what you want unless you've named the JVM target something else or created a separate test compilation
but it feels somewhat unusual to be creating a
JavaExec
from that - what are you trying to do?
if you want to include the test classes themselves and not just its runtime dependencies, you can hook into
Copy code
kotlin {
    targets {
        jvm {
            compilations.getByName("test") {
                tasks.register<JavaExec>("myJavaExecTask") {
                    classpath(runtimeDependencyFiles, output)
but if what you're trying to do is create another test task, you should use
Test
instead of
JavaExec
c
thanks that works. its part of my test runner that I’m converting to multiplatform as an experiment. it can run tests via junit engine but also as main method.
e
the right thing to do, long-term, may be to add the test framework to Gradle itself. unfortunately that's not currently a public API :-/
c
right. but running test as main method can be pretty useful to get it running on all kotlin supported platforms. its also only an experiment. jvm performance matters most for me.
e
hmm, curious. https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html#getTestFrameworkProperty-- looks like it's exposed publicly, but all the stuff connected to it isn't
c
still lots of things broken. junit engine finds no tests and idea says “kotlin not configured” after importing the project. this branch will probably not be merged soon.