Is there a way to tell Gradle to use the version o...
# community-support
l
Is there a way to tell Gradle to use the version of an indirect dependency as the version for a direct dependency? We depend on the latest version of graphql-kotin, which depends on graphql-java. It currently depends on version 21.5. We do not directly depend on graphql-java. However, we do depend on graphql-java-extended-scalars. It depends on graphql-java with the same version as itself. If we bump our dependency on graphql-java-extended-scalars to its latest version, 22.0, it pulls in graphql-java 22.0 as a runtime dependency. At the moment, this causes graphql-kotlin to break at runtime. Is there some way I can tell Gradle that we depend on graphql-java-extended-scalars, but to get the version of graphql-java that graphql-kotlin depends on, and use that as the version for graphql-java-extended-scalars?
l
I don't understand how that applies to this situation. I tried a few variations of this:
Copy code
abstract class GraphQLJavaAlignmentRule: ComponentMetadataRule {
        override fun execute(ctx: ComponentMetadataContext) {
            ctx.details.run {
                if (id.group == "com.graphql-java") {
                    belongsTo("com.expediagroup:graphql-kotlin-virtual-platform:7.1.1")
                }
            }
        }
    }

    components.all<GraphQLJavaAlignmentRule>()

    implementation("com.graphql-java:graphql-java-extended-scalars")
and Gradle always says "Could not find com.graphql-javagraphql java extended scalars."
e
actually digging into this particular situation, you don't want that anyway. those artifacts do not have the same release versions, for example graphql-java has 21.5 and graphql-java-extended-scalars does not
l
Yikes! You're right. Thanks for pointing that out. I got fooled by the fact that the groups, name-prefixes, and version numbers matched up, but it appears they are not released in sync. 🤕