Could not resolve: No matching configuration

Using the documentation as part of this library
https://giabao.github.io/play-hikaricp/#repository
I’ve added this to my project

plugins {
    `java-library`
}

repositories {
    mavenCentral()
    ivy("https://edulify.github.io/modules/releases/") {
        layout("ivy")
    }
}

dependencies {
    implementation("com.edulify:play-hikaricp_2.11:2.0.6")
}

but gradle fails to resolve

./gradlew compilej
> Task :lib:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':lib:compileJava'.
> Could not resolve all files for configuration ':lib:compileClasspath'.
   > Could not resolve com.edulify:play-hikaricp_2.11:2.0.6.
     Required by:
         project :lib
      > No matching configuration of com.edulify:play-hikaricp_2.11:2.0.6 was found. The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally but:
          - Configuration 'compile':
              - Other compatible attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its usage (required an API)
          - Configuration 'optional':
              - Other compatible attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its usage (required an API)
          - Configuration 'pom':
              - Other compatible attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its usage (required an API)
          - Configuration 'provided':
              - Other compatible attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its usage (required an API)
          - Configuration 'runtime':
              - Other compatible attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its usage (required an API)
          - Configuration 'sources':
              - Other compatible attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its usage (required an API)
          - Configuration 'test':
              - Other compatible attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its usage (required an API)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

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

BUILD FAILED in 1s
1 actionable task: 1 executed

Run it with -i -S added on the command line to get a more detailed error output.

Unfortunately no additional context that I could gleam from the output.
more_output.txt.zip (4.2 KB)

Yes, unfortunately not. I was hoping it would say WHY it could not resolve that dependency. It is difficult to say without knowing the entire configuration of your machine and project.

Browsing their repo, the artifact does seem to exist:

My guess is that something is wrong with your repository setup. Try replacing -i with -d to get debug output, and go through it to see if it shows the URL being used to try to fetch the JAR, then you can verify if that URL is valid or not.

Hmm the only new lines of output I see are

2022-02-03T08:55:52.043-0700 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :lib:compileJava FAILED
2022-02-03T08:55:52.044-0700 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter] Putting task artifact state for task ':lib:compileJava' into context took 0.0 secs.
2022-02-03T08:55:52.048-0700 [DEBUG] [org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep] Implementation for task ':lib:compileJava': org.gradle.api.tasks.compile.JavaCompile_Decorated@f9973c952e63cef776b962c21bcf4869
2022-02-03T08:55:52.048-0700 [DEBUG] [org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep] Additional implementations for task ':lib:compileJava': [org.gradle.api.tasks.compile.JavaCompile_Decorated@f9973c952e63cef776b962c21bcf4869]
2022-02-03T08:55:52.053-0700 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver] Resolving configuration ':lib:compileClasspath'
2022-02-03T08:55:52.054-0700 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.ResolvedArtifactCaches] Creating new in-memory cache for repo 'MavenRepo' [a8be1fe3b3911d3d3425fe720cf42835].
2022-02-03T08:55:52.054-0700 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.ResolvedArtifactCaches] Creating new in-memory cache for repo 'ivy' [e0f2c4ebfd4ee3540607487aff8d2e8b].
2022-02-03T08:55:52.054-0700 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.ResolvedArtifactCaches] Creating new in-memory cache for repo 'maven' [ad236a1faa9afcb90e1c3ad6cf64a95a].
2022-02-03T08:55:52.055-0700 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder] Visiting configuration edulify-help:lib:unspecified(compileClasspath).
2022-02-03T08:55:52.056-0700 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for com.edulify:play-hikaricp_2.11:2.0.6 using repositories [MavenRepo, ivy, maven]
2022-02-03T08:55:52.056-0700 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.edulify:play-hikaricp_2.11:2.0.6' in resolver cache 'MavenRepo'
2022-02-03T08:55:52.056-0700 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Using cached module metadata for module 'com.edulify:play-hikaricp_2.11:2.0.6' in 'ivy'
2022-02-03T08:55:52.056-0700 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Using com.edulify:play-hikaricp_2.11:2.0.6 from Ivy repository 'ivy'
2022-02-03T08:55:52.057-0700 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] No candidates for {org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=11, org.gradle.libraryelements=classes, org.gradle.usage=java-api} and fallback null does not match. Select nothing.
2022-02-03T08:55:52.059-0700 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in /Users/<user>/.gradle/.tmp/gradle15732273036074049440.bin. Wrote root 2.
2022-02-03T08:55:52.060-0700 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Resolve dependencies of :lib:compileClasspath' completed
2022-02-03T08:55:52.060-0700 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Snapshot inputs and outputs before executing task ':lib:compileJava'' completed
2022-02-03T08:55:52.060-0700 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter] Removed task artifact state for task ':lib:compileJava' from context.
2022-02-03T08:55:52.061-0700 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Task :lib:compileJava'
2022-02-03T08:55:52.061-0700 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Task :lib:compileJava' completed
2022-02-03T08:55:52.061-0700 [INFO] [org.gradle.execution.plan.DefaultPlanExecutor] :lib:compileJava (Thread[Execution worker for ':',5,main]) completed. Took 0.02 secs.
2022-02-03T08:55:52.061-0700 [DEBUG] [org.gradle.execution.plan.DefaultExecutionPlan] Node :lib:compileJava failed
2022-02-03T08:55:52.061-0700 [DEBUG] [org.gradle.execution.plan.DefaultExecutionPlan] Node producer locations for task group 0 completed, executed: false
2022-02-03T08:55:52.061-0700 [DEBUG] [org.gradle.execution.plan.DefaultExecutionPlan] Node :lib:compileJava completed, executed: true

This dependency does resolve in an sbt project, but the translation to gradle is failing due to this.

But it says it, right in the first post in this thread.

There are 7 configurations defined in that ivy.xml file.
And Gradle cannot decide which one to use.

ivy.xml files are very flexible regarding the configurations you define and what they might mean.
But this flexibility comes with the price that a consumer maybe cannot decide what to use without further information.

Most Ivy files I have seen so far have a configuration called default, which usually extends master and runtime.
This default configuration is, what is used by Gradle if it is found.
If it is not found, then Gradle has no choice other than asking the user which configuration he wants.

So you need to tell Gradle exactly which configuration you like to have like this:

implementation("com.edulify:play-hikaricp_2.11:2.0.6") {
    targetConfiguration = "runtime"
}
2 Likes

Brilliant, that was it! Thank you so much!

The closest I had just got was to map the runtime variant to some new added variant, based on the variant model docs page, but I couldn’t make the final logical leap to setting the targetConfiguration.

dependencies.components.withModule("com.edulify:play-hikaricp_2.11") {
    addVariant("notsurewhatthisis", "runtime") { }
}

Again, I can’t thank you enough.

You can of course also create a variant and let the variant-aware resolution do its work. It doesn’t really matter how you name the variant. The important part is, that you add the proper attributes so that the variant aware resolution can decide which to use. This is for example helpful if you want the compile configuration (with its dependencies) for compilation, but the runtime configuration (with its dependencies) for execution to keep your compile class path as small as sensible and thus speed up the build and increase likeliness for up-to-date, for example if only a runtime dependency changed.
But in this specific case there are only compile, test, and provided dependencies anyway.

1 Like