This might be a weird one... Is there a way to def...
# multiplatform
d
This might be a weird one... Is there a way to define a Gradle configuration that only applies to ONE of the platform targets? (More details in 🧵)
Basically something like this:
Copy code
kotlin {
  js()
  jvm()

  jsMain.dependencies {
    jvmJar(project(":jvmProject")) // Invalid
  }

  jvmMain.dependencies {
    jvmJar(project(":jvmProject")) // Valid
  }
}
I have a configuration that represents jars that get copied over into a plugins folder. This only makes sense inside the JVM project.
What I'd love to do is prevent autocompletion for the configuration from even working in a non-JVM target. But I would also be OK catching the issue at configuration time and throwing an exception.
(The receiving scope for both dependencies blocks are
KotlinDependencyHandler
which as far as I can tell don't have a way to get associated with the target they represent, but I could be missing something)
It would even be interesting to know if it's a test target or a main target, but I'd understand if that isn't possible.
I ended up thinking that maybe I was barking up the wrong tree here. I ended up creating a configuration you set in the top-level dependencies block, like this, side-stepping the whole issue:
Copy code
dependencies {
  jvmJar(...)
}

kotlin {
  js()
  jvm()

  ...
}