title: Gradle Kotlin, Cucumber, and OKHttp
body: <p>I'm trying to set up a spring boot project in Kotlin with OkHttp and Cucumber and getting the following error when running the cucumber task.  How do I fix?</p>
  
  <pre><code>Execution failed for task ':cucumber'.
  &gt; Could not resolve all files for configuration ':cucumberRuntime'.
     &gt; Could not resolve com.squareup.okio:okio:2.4.1.
       Required by:
           project : &gt; com.squareup.okhttp3:okhttp:4.3.1
        &gt; Cannot choose between the following variants of com.squareup.okio:okio:2.4.1:
            - jvm-api
            - jvm-runtime
            - metadata-api
          All of them match the consumer attributes:
            - Variant 'jvm-api' capability com.squareup.okio:okio:2.4.1:
                - Unmatched attributes:
                    - Found org.gradle.libraryelements 'jar' but wasn't required.
                    - Found org.gradle.status 'release' but wasn't required.
                    - Found org.gradle.usage 'java-api' but wasn't required.
                    - Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
            - Variant 'jvm-runtime' capability com.squareup.okio:okio:2.4.1:
                - Unmatched attributes:
                    - Found org.gradle.libraryelements 'jar' but wasn't required.
                    - Found org.gradle.status 'release' but wasn't required.
                    - Found org.gradle.usage 'java-runtime' but wasn't required.
                    - Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
            - Variant 'metadata-api' capability com.squareup.okio:okio:2.4.1:
                - Unmatched attributes:
                    - Found org.gradle.status 'release' but wasn't required.
                    - Found org.gradle.usage 'kotlin-api' but wasn't required.
                    - Found org.jetbrains.kotlin.platform.type 'common' but wasn't required.
  
  </code></pre>
  
  <p>and the build gradle kts snippet</p>
  
  <pre><code>import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
  
  plugins {
      id("org.springframework.boot") version "2.2.5.RELEASE"
      id("io.spring.dependency-management") version "1.0.9.RELEASE"
      kotlin("jvm") version "1.3.61"
      kotlin("plugin.spring") version "1.3.61"
  }
  
  group = "com.foo"
  version = "0.0.1-SNAPSHOT"
  java.sourceCompatibility = JavaVersion.VERSION_11
  
  val developmentOnly by configurations.creating
  configurations {
      runtimeClasspath {
          extendsFrom(developmentOnly)
      }
      compileOnly {
          extendsFrom(configurations.annotationProcessor.get())
      }
  }
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      implementation("org.springframework.boot:spring-boot-starter-web")
      implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
      implementation("org.jetbrains.kotlin:kotlin-reflect")
      implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
  
      compileOnly("org.projectlombok:lombok")
      developmentOnly("org.springframework.boot:spring-boot-devtools")
      annotationProcessor("org.projectlombok:lombok")
  
      implementation("com.squareup.okhttp3:okhttp:4.3.1")
      implementation("com.graphql-java-kickstart:graphql-spring-boot-starter:6.0.1")
      runtimeOnly("com.graphql-java-kickstart:graphiql-spring-boot-starter:6.0.1")
      runtimeOnly("com.graphql-java-kickstart:voyager-spring-boot-starter:6.0.1")
  
      testImplementation("io.cucumber:cucumber-java8:5.4.0")
      testImplementation("io.cucumber:cucumber-junit:5.4.0")
      testImplementation("org.springframework.boot:spring-boot-starter-test") {
          exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
      }
  }
  
  tasks.withType&lt;Test&gt; {
      useJUnitPlatform()
  }
  
  tasks.withType&lt;KotlinCompile&gt; {
      kotlinOptions {
          freeCompilerArgs = listOf("-Xjsr305=strict")
          jvmTarget = "11"
      }
  }
  
  val cucumberRuntime by configurations.creating {
      extendsFrom(configurations["testImplementation"])
  }
  
  task("cucumber") {
      dependsOn("assemble")
      dependsOn("compileTestJava")
      doLast {
          javaexec {
              main = "io.cucumber.core.cli.Main"
              classpath = cucumberRuntime + sourceSets.main.get().output + sourceSets.test.get().output
              args = listOf("--plugin", "pretty", "--glue", "gradle.cucumber", "src/test/resources")
          }
      }
  }
  
  
  </code></pre>
  
  <p>I saw this error <a href="https://github.com/square/okio/issues/647" rel="nofollow noreferrer">https://github.com/square/okio/issues/647</a> that seems like it could be it and a fix with this build.gradle, how would I translate this to kotlin for a build.gradle.kts?</p>
  
  <pre><code>subprojects { subProject -&gt;
    ...
  
    configurations.all { configuration -&gt;
      // Workaround for kapt bug with MPP dependencies
      // https://youtrack.jetbrains.com/issue/KT-31641
      // https://youtrack.jetbrains.com/issue/KT-33206
      if (name.contains('kapt') || name.contains("wire")) {
        attributes.attribute(Usage.USAGE_ATTRIBUTE, subProject.objects.named(Usage.class, Usage.JAVA_RUNTIME))
      }
    }
  </code></pre>