using `kotlin-multiplatform` plugin, is it possibl...
# gradle
l
using
kotlin-multiplatform
plugin, is it possible to create a sourceSet from a folder that’s sibling to the module that I’m currently configuring? As in, I have modules A and B, like so:
Copy code
moduleA
  test
  testShared
  build.gradle.kts
moduleB
  test
  build.gradle.kts
I would like to include
testShared
when running
:moduleB:test
What I have on moduleA:
Copy code
val jvmTestShared by creating
    val jvmTest by getting {
      dependencies {
        dependsOn(jvmTestShared)
      }
    }
but I can’t seem to be able to create
jvmTestShared
on moduleB
j
it is impossible that
val jvmTestShared by creating
can find a folder outside of the same module
anyway you should not run
:test
you should run
allTest
for example
test task is for running jvm tests in jvm libraries, not sure what it even do in kmp environment
l
oh, I guess I meant to run
:jvmTest
, because I only care to share
testShared
to JVM targets
j
they are different targets so you should change your structure if you want to get that or just do something like
tasks.findByName("jvmTest")?.dependsOn("jvmTestShared")
, but probably the structure is not correct and should be changed
you can add the jvmTestShared to jvmTest without creating a new target for example
by adding that folder to the jvmTest source dirs
l
right, the directories
test
and
testShared
could be merged but I’m still unsure how to have
testShared
be included on let’s say
moduleC
, `moduleD`’s
jvmTest
does it make sense? i hope I’m not doing the XYproblem thingy
j
why you can't create a specific module which has those tests and add it as dependency in all modules that use it?
testShared moduleA -> testShared moduleB -> testShared and so on
l
let me try that
j
you can add it to jvmTest or commonTest too if it is kmp
l
I’m not sure how to execute the (jvm) tests that exist on
testShared
together with the (jvm) tests of e.g.
moduleA
. What I did was to create a new Gradle (testShared) module, add these ArchUnit tests as part of the main sourceSet, and then add as
api(":testShared")
to moduleA’s like so:
Copy code
val jvmTest by getting {
      dependencies {
        implementation(projects.testShared)
      }
    }
v
Actually sounds like a use-case for the
test-fixtures
plugin, I just don't know how well it works at this time with KMP builds.
j
I think it doesnt, or maybe it doesnt work with Android, at least last time I checked that, long time ago tho
l
does fixtures also include tests? That was my initial rationale
v
It is code. Whether the code is a test or just a helper should not be relevant I think. Unless the test framework does not look into the classpath for tests or something like that.