Closed
Description
productionRuntimeClasspath
resolution fails for Kotlin-multiplatform project dependencies.
Note: ./gradlew jar
works, and bootJar
works with Spring Boot 2.2.6.RELEASE
Environment:
Gradle 6.3
Spring Boot 2.3.0.RELEASE (fails)
Kotlin 1.3.72
Execution failed for task ':parser:bootJar'.
> Could not resolve all files for configuration ':parser:productionRuntimeClasspath'.
> Could not resolve project :common.
Required by:
project :parser
> Cannot choose between the following variants of project :common:
- jsApiElements
- jsCompile
- jsCompileOnly
- jsDefault
- jsRuntime
- jsRuntimeElements
- jsTestCompile
- jsTestRuntime
- jvmApiElements
- jvmCompile
- jvmCompileOnly
- jvmDefault
- jvmRuntime
- jvmRuntimeElements
- jvmTestCompile
- jvmTestRuntime
- metadataApiElements
- metadataCompile
- metadataCompileOnly
- metadataDefault
All of them match the consumer attributes:
- Variant 'jsApiElements' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.gradle.usage 'kotlin-api' but wasn't required.
- Found org.jetbrains.kotlin.localToProject 'public' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'js' but wasn't required.
- Variant 'jsCompile' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.jetbrains.kotlin.localToProject 'local to :common' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'js' but wasn't required.
- Variant 'jsCompileOnly' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.jetbrains.kotlin.localToProject 'local to :common' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'js' but wasn't required.
- Variant 'jsDefault' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.jetbrains.kotlin.localToProject 'local to :common' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'js' but wasn't required.
- Variant 'jsRuntime' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.jetbrains.kotlin.localToProject 'local to :common' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'js' but wasn't required.
- Variant 'jsRuntimeElements' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.gradle.usage 'kotlin-runtime' but wasn't required.
- Found org.jetbrains.kotlin.localToProject 'public' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'js' but wasn't required.
- Variant 'jsTestCompile' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.jetbrains.kotlin.localToProject 'local to :common' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'js' but wasn't required.
- Variant 'jsTestRuntime' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.jetbrains.kotlin.localToProject 'local to :common' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'js' but wasn't required.
- Variant 'jvmApiElements' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.gradle.libraryelements 'jar' but wasn't required.
- Found org.gradle.usage 'java-api' but wasn't required.
- Found org.jetbrains.kotlin.localToProject 'public' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
- Variant 'jvmCompile' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.jetbrains.kotlin.localToProject 'local to :common' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
- Variant 'jvmCompileOnly' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.jetbrains.kotlin.localToProject 'local to :common' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
- Variant 'jvmDefault' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.jetbrains.kotlin.localToProject 'local to :common' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
- Variant 'jvmRuntime' capability com.example:common:1.0.0:
- Unmatched attributes:
- Found org.jetbrains.kotlin.localToProject 'local to :common' but wasn't required.
- Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
...
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
Stop developmentOnly from removing too much from executable jars and …
wilkinsona commentedon May 26, 2020
Thanks for the report. It looks like a change in Boot 2.3 may have shaken loose another example of a problem that Kotlin's Gradle support has had in the past. While we may be able to copy attributes from an existing configuration to the
productionRuntimeClasspath
configuration that we create, that feels rather brittle. IMO, Kotlin's Gradle support should handle this itself rather than relying on the rest of the ecosystem understanding and adding Kotlin-specific attributes to any configurations that they may create.wilkinsona commentedon May 26, 2020
@vlsi Can you please try the workaround mentioned in the issue I linked to above. Without a sample it's hard to tell exactly how it should look for you, but I think it should be something like the following:
Also, to help us to investigate further and decide if there's anything we can do in Spring Boot or if the problem needs to be addressed entirely on the Kotlin side, can you please provide a minimal sample that reproduces the failure you're seeing? You can do so by zipping something up and attaching it to this issue or by pushing it to a separate repository on GitHub.
vlsi commentedon May 26, 2020
I feel your pain, however, the project is not open, and that is the only Kotlin multiplatform + Spring Boot project I have. It would take me time to share a reproducer.
I believe the issue is NOT Kotlin-specific.
It provides regular Gradle attributes:
org.gradle.libraryelements=jar and org.gradle.usage=java-runtime has nothing to do with Kotlin. They are regular attributes for a Java project.
However,
productionRuntimeClasspath
does not request the attributes, that is why Gradle can't choose between the variants.The following workaround works:
implementation(project(":common", "jvmRuntimeElements"))
, however, I believe it is a workaround.The following workaround works as well:
However, I don't quite follow the following code in SpringBoot
productionRuntimeClasspath.setExtendsFrom(runtimeClasspath.getExtendsFrom());
What was the purpose there?
Did you mean
productionRuntimeClasspath.setExtendsFrom(runtimeClasspath)
?I don't think it is safe to assume that
runtimeClasspath.getExtendsFrom()
resolves to something meaningful and stable. It is likely Gradle's implementation detail.vlsi commentedon May 26, 2020
TL;DR: please use Gradle-provided configurations (e.g.
runtimeClasspath
) or request the proper attributes in your configurations (see example 8 in https://docs.gradle.org/current/userguide/cross_project_publications.html )wilkinsona commentedon May 26, 2020
Setting the usage attribute makes sense. Thanks for the suggestion.
To create a configuration that extends from the same configurations as
runtimeClasspath
. Ultimately, the goal is to create a configuration that contains everything inruntimeClasspath
other than dependencies that are unique to Boot'sdevelopmentOnly
configuration.No. If
productionRuntimeClasspath
extends fromruntimeClasspath
, then it will end up including the dependencies indevelopmentOnly
.[-]2.3.0 regression: productionRuntimeClasspath fails to resolve multiplatform dependency variants [/-][+]productionRuntimeClasspath fails to resolve multiplatform dependency variants [/+]