ben-manes / gradle-versions-plugin

Gradle plugin to discover dependency updates
Apache License 2.0
3.87k stars 200 forks source link

Failed to determine the latest version for the following dependencies: - io.ktor:ktor-client-js #438

Closed christophsturm closed 4 years ago

christophsturm commented 4 years ago

this is probably related to the two closed issues with the same exception, but its still occuring so I'm opening a new issue for it:

this probably happens with all kotlin mpp projects that use ktor-client-js or the kotlin react wrappers (https://github.com/JetBrains/kotlin-wrappers)

Failed to determine the latest version for the following dependencies (use --info for details):
 - io.ktor:ktor-client-js
The exception that is the cause of unresolved state: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve io.ktor:ktor-client-js:+.
Required by:
    project :
Caused by: org.gradle.internal.component.AmbiguousConfigurationSelectionException: Cannot choose between the following variants of io.ktor:ktor-client-js:1.4.1:
  - metadata-api
  - metadata-commonMainMetadataElements
All of them match the consumer attributes:
  - Variant 'metadata-api' capability io.ktor:ktor-client-js:1.4.1:
      - Unmatched attributes:
          - Provides org.gradle.status 'release' but the consumer didn't ask for it
          - Provides org.gradle.usage 'kotlin-metadata' but the consumer didn't ask for it
          - Provides org.jetbrains.kotlin.platform.type 'common' but the consumer didn't ask for it
  - Variant 'metadata-commonMainMetadataElements' capability io.ktor:ktor-client-js:1.4.1:
      - Unmatched attributes:
          - Provides org.gradle.status 'release' but the consumer didn't ask for it
          - Provides org.gradle.usage 'kotlin-api' but the consumer didn't ask for it
          - Provides org.jetbrains.kotlin.platform.type 'common' but the consumer didn't ask for it
        at org.gradle.internal.component.model.AttributeConfigurationSelector.selectConfigurationUsingAttributeMatching(AttributeConfigurationSelector.java:105)
        at org.gradle.internal.component.model.AttributeConfigurationSelector.selectConfigurationUsingAttributeMatching(AttributeConfigurationSelector.java:108)
        at org.gradle.internal.component.model.AttributeConfigurationSelector.selectConfigurationUsingAttributeMatching(AttributeConfigurationSelector.java:51)
        at org.gradle.internal.component.model.LocalComponentDependencyMetadata.selectConfigurations(LocalComponentDependencyMetadata.java:144)
        at org.gradle.internal.component.local.model.DslOriginDependencyMetadataWrapper.selectConfigurations(DslOriginDependencyMetadataWrapper.java:71)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.EdgeState.calculateTargetConfigurations(EdgeState.java:265)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.EdgeState.attachToTargetConfigurations(EdgeState.java:150)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.attachToTargetRevisionsSerially(DependencyGraphBuilder.java:364)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.resolveEdges(DependencyGraphBuilder.java:249)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:186)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:145)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver.resolve(DefaultArtifactDependencyResolver.java:137)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver.resolveGraph(DefaultConfigurationResolver.java:178)
        at org.gradle.api.internal.artifacts.ivyservice.ShortCircuitEmptyConfigurationResolver.resolveGraph(ShortCircuitEmptyConfigurationResolver.java:85)
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.resolveGraph(ErrorHandlingConfigurationResolver.java:74)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$1.call(DefaultConfiguration.java:615)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$1.call(DefaultConfiguration.java:606)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveGraphIfRequired(DefaultConfiguration.java:606)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.lambda$resolveExclusively$4(DefaultConfiguration.java:586)
        at org.gradle.api.internal.project.DefaultProjectStateRegistry$CalculatedModelValueImpl.update(DefaultProjectStateRegistry.java:361)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveExclusively(DefaultConfiguration.java:583)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveToStateOrLater(DefaultConfiguration.java:570)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:545)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
        at com.github.benmanes.gradle.versions.updates.Resolver.resolve(Resolver.groovy:80)
        at com.github.benmanes.gradle.versions.updates.DependencyUpdates.resolve(DependencyUpdates.groovy:85)
        at com.github.benmanes.gradle.versions.updates.DependencyUpdates.access$0(DependencyUpdates.groovy)
        at com.github.benmanes.gradle.versions.updates.DependencyUpdates$_resolveProjects_closure6$_closure10.doCall(DependencyUpdates.groovy:75)
        at jdk.internal.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
        at groovy.lang.Closure.call(Closure.java:405)
        at groovy.lang.Closure.call(Closure.java:421)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(DefaultGroovyMethods.java:3574)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(DefaultGroovyMethods.java:3559)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(DefaultGroovyMethods.java:3659)
        at com.github.benmanes.gradle.versions.updates.DependencyUpdates$_resolveProjects_closure6.doCall(DependencyUpdates.groovy:70)
        at com.github.benmanes.gradle.versions.updates.DependencyUpdates$_resolveProjects_closure6.call(DependencyUpdates.groovy)

the exception is from one of my non open source projects but i can create a test project if needed.

ben-manes commented 4 years ago

A test project would be great.

christophsturm commented 4 years ago

here you are: https://github.com/christophsturm/mpp-test

./gradlew dependencyUpdates --info

ben-manes commented 4 years ago

I tried the following to capture the metadata but wasn't successful.

  1. Checked configuration & dependency attributes (copied)
  2. No dependency capabilities to copy
  3. No configuration dependency constraints to copy
  4. No exclusion rules to copy
  5. Extending from super configurations didn't help
  6. Adding incoming dependencies & capabilities didn't help
  7. Enabling transitive dependencies didn't help

The kotlin plugin likes to refer to tasks by name to enhance them, which is brittle and not the "Gradle way". Instead they should do it by a matching condition and configure them during the init phase, so that copying captures the full definition. That may be at play here since we copy to rewrite the dependency versions, but they have a lot of code and it is complex, so I can't reverse engineer the cause at this time.

Can you get their developers to help us?

ben-manes commented 4 years ago

The variant guide indicates that us copying the attributes should work, but not in this case. Running :outgoingVariants shows platform.type: js but we do copy both configuration & dependency attributes, so this appears to be set. The exact magic to be MPP compatible escapes me...

christophsturm commented 4 years ago

I posted the link to this ticket on the kotlin slack and asked for help, but did not get a reaction. where in the plugin sourcecode would i need to start looking if i want to have a look myself?

ben-manes commented 4 years ago

hah, I got it!

Looking at the Kotlin plugin's code for commonMainMetadataElements shows a dynamically added configuration that adds legacy metadata. By querying if it exists and extending it in the copy, your project resolves without any failures. This appears to be a legacy compatibility shim that we have to special case.

I'm doing some extra testing but so far it looks good.

ben-manes commented 4 years ago

Verified this also fixes @Vampire's setup-wsdl project where he had this problem, too.

I'll cut a release for 0.34, though it may take an hour or two for the jcenter => portal sync.

christophsturm commented 4 years ago

pretty cool!

nagkumar commented 1 year ago

I see the similar issue..

------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------

The following dependencies are using the latest milestone version:
 - com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin:0.46.0
 - org.pitest:pitest-command-line:1.9.11
 - org.pitest:pitest-junit5-plugin:1.1.2
 - se.patrikerdes.use-latest-versions:se.patrikerdes.use-latest-versions.gradle.plugin:0.2.18

Failed to determine the latest version for the following dependencies (use --info for details):
 - com.adarshr.test-logger:com.adarshr.test-logger.gradle.plugin
 - com.approvaltests:approvaltests
 - com.approvaltests:approvaltests-util
 - com.fasterxml.jackson:jackson-bom
 - com.fasterxml.jackson.core:jackson-databind
 - com.groupcdg:pitest-annotations
 - com.pholser:junit-quickcheck-core
 - com.pholser:junit-quickcheck-generators
 - de.sormuras.mainrunner:de.sormuras.mainrunner.api
 - de.sormuras.mainrunner:de.sormuras.mainrunner.engine
 - info.solidsoft.pitest:info.solidsoft.pitest.gradle.plugin
 - io.cucumber:cucumber-bom
 - io.cucumber:cucumber-java
 - io.cucumber:cucumber-junit-platform-engine
 - io.freefair.aspectj.post-compile-weaving:io.freefair.aspectj.post-compile-weaving.gradle.plugin
 - junit:junit
 - net.jqwik:jqwik
 - org.aspectj:aspectjrt
 - org.aspectj:aspectjweaver
 - org.junit:junit-bom
 - org.junit.jupiter:junit-jupiter
 - org.junit.jupiter:junit-jupiter-engine
 - org.junit.jupiter:junit-jupiter-params
 - org.junit.platform:junit-platform-suite
 - org.junit.support:testng-engine
 - org.junit.vintage:junit-vintage-engine
 - org.pitest:pitest
 - org.testng:testng

Gradle release-candidate updates:
 - Gradle: [8.1 -> 8.1.1]

May be it is unable to resolve for these kinds of bom dependencies

_dependencies { implementation(platform("org.junit:junit-bom:$jjVersion"))

implementation("org.junit.jupiter:junit-jupiter")
implementation("org.junit.jupiter:junit-jupiter-params")
implementation("org.junit.platform:junit-platform-suite")

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")

implementation("org.pitest:pitest:1.12.0")
implementation("com.groupcdg:pitest-annotations:1.0.7")

implementation("com.approvaltests:approvaltests:18.6.0")
implementation("com.approvaltests:approvaltests-util:18.6.0")

implementation("org.aspectj:aspectjrt:$ajcVersion")
implementation("org.aspectj:aspectjweaver:$ajcVersion")

implementation("net.jqwik:jqwik:1.7.3")

implementation("de.sormuras.mainrunner:de.sormuras.mainrunner.api:2.1.4")
implementation("de.sormuras.mainrunner:de.sormuras.mainrunner.engine:2.1.4")

implementation("junit:junit:4.13.2")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")

implementation("org.testng:testng:7.7.0")
testRuntimeOnly("org.junit.support:testng-engine:1.0.4")

implementation(platform("io.cucumber:cucumber-bom:7.11.2"))
implementation("io.cucumber:cucumber-java")
implementation("io.cucumber:cucumber-junit-platform-engine")

implementation(platform("com.fasterxml.jackson:jackson-bom:2.14.2"))
implementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")

implementation("com.pholser:junit-quickcheck-core:1.0")
implementation("com.pholser:junit-quickcheck-generators:1.0")

}_

My plugins are

plugins {
    id("java")
    id("idea")

    id("info.solidsoft.pitest") version ("1.9.11")

    id("com.adarshr.test-logger") version "3.2.0"

    id("io.freefair.aspectj.post-compile-weaving") version "8.0.1"

    id("se.patrikerdes.use-latest-versions") version "0.2.18"
    id("com.github.ben-manes.versions") version "0.46.0"
}
ben-manes commented 1 year ago

@nagkumar What is the exception with --info? It is usually a configuration issue, but it can be a little painful to debug Gradle builds...

nagkumar commented 1 year ago

Thank You I ran it gain now.. everything works fine now.. looks like it is random, I shall further note this and let you know the info log when it happens again..