profile
viewpoint

Ask questionsDependency resolution fails with Gradle 5.3.x to 5.6.x

I just tried to install v2.2.3 by updating the Gradle plugin:

plugins {
        id "org.springframework.boot" version "2.2.3.RELEASE" // was 2.2.2.RELEASE
}

However, when I try to build, I get the following dependency resolution error:

> Could not resolve all files for configuration ':example:detachedConfiguration17'.
   > Could not resolve org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.3.
     Required by:
         project :example
      > Cannot choose between the following variants of org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.3:
          - enforcedRuntimeElements
          - runtimeElements
        All of them match the consumer attributes:
          - Variant 'enforcedRuntimeElements' capability org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.3:
              - Unmatched attributes:
                  - Found org.gradle.category 'enforced-platform' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.gradle.usage 'java-runtime' but wasn't required.
          - Variant 'runtimeElements' capability org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.3:
              - Unmatched attributes:
                  - Found org.gradle.category 'platform' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.gradle.usage 'java-runtime' but wasn't required.

This is with a pure-Java project (not using Kotlin).

spring-projects/spring-boot

Answer questions wilkinsona

Thanks for letting us know and sorry for the inconvenience.

The problem’s caused by spring-boot-dependencies upgrading from Kotlin Coroutines 1.3.2 to 1.3.3. Unfortunately this affects pure-Java projects as the Kotlin Coroutines bom is imported in the spring-boot-dependencies bom.

Kotlin Coroutines started publishing Gradle Module Metadata in 1.3.3. They’re building with Gradle 5.6.x and, unfortunately, the metadata it produced breaks resolution of the pom by the dependency management plugin. This is due to a bug in the metadata. Gradle 6 works around this bug on the consuming side by ignored metadata published with Gradle 5. It also corrects the metadata on the producing side. As you have seen, this means that the problem can be avoided by upgrading your build to Gradle 6. It could also be fixed by the Kotlin team doing the same and publishing a new release with updated metadata.

You should be able to work around the problem by overriding the version of the Kotlin Coroutines bom that is imported by Boot’s dependency management:

ext['kotlin-coroutines.version']='1.3.2'

This should allow you to use Gradle 4.x or 5.x.

I’m not yet sure what the way forward should be for Boot 2.2.x. We do not want to require Gradle 6 until Boot 2.4. We also do not want to get stuck on Kotlin Coroutines 1.3.2 in the long term. We may be able to work around the problem in the dependency management plugin or we may be able to get the Kotlin team to make a change to either stop publishing the metadata until they upgrade to Gradle 6. In the meantime, please try the workaround above and let us know if the problem persists.

useful!

Related questions

Controller annotated with @Timed and active TimedAspect clashes with WebMvcMetricsFilter hot 2
Actuator: NPE in LongTaskTimingHandlerInterceptor hot 2
spring boot Servlet.service() for servlet [dispatcherServlet] in context with path threw exception hot 2
Migrating OAuth2 from Spring Boot 1.5 to 2.0 Broken hot 2
Classloading problems with Spring Boot, JDK11 and Security Manager hot 1
java.lang.NullPointerException: null occurs in HttpExchangeTracer hot 1
Multiple data source projects cannot be started hot 1
get error messag Could not fetch the SequenceInformation from the database, hibernate_sequence doesn't exist hot 1
HttpTraceFilter bean missing hot 1
A java.lang.NoClassDefFoundError: ch/qos/logback/classic/spi/ThrowableProxy was thrown when killing my app hot 1
Source file must be provided failure when running spring-boot:repackage from the command-line hot 1
Issue with spring boot v2.1.2 with DocumentBuilderFactory.setFeature(String) hot 1
ErrorPageFilter ignores REST response in case of Exception hot 1
ConfigurationProperties with constructor binding cannot be mocked hot 1
Improve diagnostics when configuration property scanning and component scanning both create a bean for the same class hot 1
Github User Rank List