Dependency on a webpack bundle file generated by kotlin-frontend-plugin


#1

I use kotlin-frontend-plugin to generate a webpack bundle.
Everything works fine, a my-client.jar is generated containing the main.bundle.js webpack bundle file.

What I would like is to use this my-client.jar file as a runtime dependency of my Spring Boot application:

runtime project(":my-client")

Unfortunatelly this fails:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':my-server:bootJar'.
> Could not resolve all task dependencies for configuration ':my-server:runtimeClasspath'.
   > Could not resolve project :my-client.
     Required by:
         project :my-server
      > Unable to find a matching variant of project :my-client:
          - Variant 'apiElements':
              - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'js'.
          - Variant 'runtimeElements':
              - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime-jars'.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found in

Do you have any idea what this error message means in practice? :slight_smile:
I tried to use the runtimeElements scope instead of runtime but it fails too…


#2

This breaking change is alredy known. There is a small discussion inside official bugtracker[1].
It will be fixed in version 1.2.72 (according to bugtracker at this moment).

[1] https://youtrack.jetbrains.net/issue/KT-26834


#3

I still have this error in kotlin 1.3.0, wasn’t it fixed?

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':backend:run'.
> Could not resolve all task dependencies for configuration ':backend:runtimeClasspath'.
   > Could not resolve project :frontend.
     Required by:
         project :backend
      > Unable to find a matching variant of project :frontend:
          - Variant 'apiElements':
              - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-api'.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'js'.
          - Variant 'compile':
              - Required org.gradle.usage 'java-runtime' but no value provided.
              - Found org.jetbrains.kotlin.localToProject ':frontend' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'js'.
          - Variant 'compileOnly':
              - Required org.gradle.usage 'java-runtime' but no value provided.
              - Found org.jetbrains.kotlin.localToProject ':frontend' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'js'.
          - Variant 'default':
              - Required org.gradle.usage 'java-runtime' but no value provided.
              - Found org.jetbrains.kotlin.localToProject ':frontend' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'js'.
          - Variant 'runtime':
              - Required org.gradle.usage 'java-runtime' but no value provided.
              - Found org.jetbrains.kotlin.localToProject ':frontend' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'js'.
          - Variant 'runtimeElements':
              - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-runtime'.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'js'.
          - Variant 'testCompile':
              - Required org.gradle.usage 'java-runtime' but no value provided.
              - Found org.jetbrains.kotlin.localToProject ':frontend' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'js'.
          - Variant 'testCompileOnly':
              - Required org.gradle.usage 'java-runtime' but no value provided.
              - Found org.jetbrains.kotlin.localToProject ':frontend' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'js'.
          - Variant 'testRuntime':
              - Required org.gradle.usage 'java-runtime' but no value provided.
              - Found org.jetbrains.kotlin.localToProject ':frontend' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'js'.
   > Could not resolve project :sfn-adapters-core:frontend-core.
     Required by:
         project :backend > project :sfn-adapters-core:backend-core
      > Unable to find a matching variant of project :sfn-adapters-core:frontend-core:
          - Variant 'apiElements':
      > Unable to find a matching variant of project :sfn-adapters-c
          - Variant 'apiElements':
              - Required org.gradle.usage 'java-runtime' and found i
              - Required org.jetbrains.kotlin.platform.type 'jvm' an
          - Variant 'compile':
              - Required org.gradle.usage 'java-runtime' but no valu
              - Found org.jetbrains.kotlin.localToProject ':sfn-adap
              - Required org.jetbrains.kotlin.platform.type 'jvm' an
          - Variant 'compileOnly':
              - Required org.gradle.usage 'java-runtime' but no valu
              - Found org.jetbrains.kotlin.localToProject ':sfn-adap
              - Required org.jetbrains.kotlin.platform.type 'jvm' an
          - Variant 'default':
              - Required org.gradle.usage 'java-runtime' but no valu
              - Found org.jetbrains.kotlin.localToProject ':sfn-adap
              - Required org.jetbrains.kotlin.platform.type 'jvm' an
          - Variant 'runtime':
              - Required org.gradle.usage 'java-runtime' but no valu
              - Found org.jetbrains.kotlin.localToProject ':sfn-adap
              - Required org.jetbrains.kotlin.platform.type 'jvm' an
          - Variant 'runtimeElements':
              - Required org.gradle.usage 'java-runtime' and found i
              - Required org.jetbrains.kotlin.platform.type 'jvm' an
          - Variant 'testCompile':
              - Required org.gradle.usage 'java-runtime' but no valu
              - Found org.jetbrains.kotlin.localToProject ':sfn-adap
              - Required org.jetbrains.kotlin.platform.type 'jvm' an
          - Variant 'testCompileOnly':
              - Required org.gradle.usage 'java-runtime' but no valu
              - Found org.jetbrains.kotlin.localToProject ':sfn-adap
              - Required org.jetbrains.kotlin.platform.type 'jvm' an
          - Variant 'testRuntime':
              - Required org.gradle.usage 'java-runtime' but no valu
              - Found org.jetbrains.kotlin.localToProject ':sfn-adap
              - Required org.jetbrains.kotlin.platform.type 'jvm' an

* Try:
Run with --stacktrace option to get the stack trace. Run with --info
sights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

#4

The original problem has been fixed:
https://youtrack.jetbrains.net/issue/KT-26834#focus=streamItem-27-3150034-0-0