Hi, we’re working on a multiplatform project and w...
# gradle
o
Hi, we’re working on a multiplatform project and would like to share common test utilities between test sourceSets residing in different gradle modules. What is the best approach?
t
yeah, curious to know. my approach so far is to generate an artifact:
Copy code
tasks {
  register<Jar>("jarTest") {
    dependsOn(testClasses)
    from(sourceSets["test"].output)
    archiveClassifier.set("testHelper")
  }

  jar {
    dependsOn(named<Jar>("jarTest"))
  }
}

val testHelper by configurations.creating

artifacts {
  add(testHelper.name, tasks.named<Jar>("jarTest").get())
}
wondering if there are better approaches/implementation
t
Gradle 6 introduced the feature of
sharing test fixtures between projects
(https://gradle.org/whats-new/gradle-6/#sharing-test-fixtures-between-projects)
Maybe it can help.
t
interesting, did not know that. I am currently having problem with the fixtures being written in kotlin
*Task :domain:compileTestFixturesKotlin* FAILED DomainFactories.kt: (8, 37): Cannot access built-in declaration 'kotlin.Boolean'. Ensure that you have a dependency on the Kotlin standard library
but guess I can find a solution
👍 1
o
Thansk for the answers. We will probarly go with Marco´s suggestion.
t
it was actually harder than I thought because of https://github.com/gradle/gradle/issues/11696 and ofc it took me my own sample project to figure out I had a problem with test fixtures and spring boot plugin and know what to look for
but now that test fixtures work, quite nice not having to create the test jar manually 🙂
👏 1
t
Great @thanksforallthefish! Thanks for sharing 😄