title: How to access tests jar in gradle in multi-module project
body: <p>I have multimodule project. From one of the modules I need to refer the test classes from other module. I tried to configure like this:</p>
  
  <pre><code>// core project
  val testJar by tasks.registering(Jar::class) {
      archiveClassifier.set("tests")
      from(project.the&lt;SourceSetContainer&gt;()["test"].output)
  }
  val testArtifact by configurations.creating
  artifacts.add(testArtifact.name, testJar)
  </code></pre>
  
  <p>And I'm trying to refer to that configuration from other project:</p>
  
  <pre><code>dependencies {
      // other dependencies ommited
      api(project(":core"))
      testImplementation(project(path = ":core", configuration = "testArtifact"))
  }
  </code></pre>
  
  <p>But this configuration doesn't work. The compilation of other project is failing as it doesn't see the required tests classes from <code>core</code> project. The dependency insight:</p>
  
  <pre><code>./gradlew :service:dependencyInsight --dependency core --configuration testCompileClasspath
  </code></pre>
  
  <p>It gives following:</p>
  
  <pre><code>project :core
    variant "apiElements" [
      org.gradle.usage = java-api
    ]
    variant "testArtifact" [
      Requested attributes not found in the selected variant:
        org.gradle.usage = java-api
    ]
  </code></pre>
  
  <p>I'm struggling to understand how to make configuration to work so that I can compile the <code>service</code> project's test classes. Running on Gradle 5.2.1 with Kotlin DSL.</p>