This message was deleted.
# community-support
s
This message was deleted.
l
Thanks! How does one determine whether there’s a BOM available for a given set of modules? It looks like graphql-java is published with Gradle, but I don’t see a bom when I search on mvnrepository.
BOM and Gradle Module Metadata are two different things that can both be useful, but this project publishes neither
so if you want to align versions, you'll have to do so yourself, which the document I linked earlier also describes how to do
l
So we’d have to use the “Align versions of modules without a published platform” instructions? Perhaps something like this?
Copy code
abstract class GraphQLJavaAlignmentRule implements ComponentMetadataRule {
    void execute(ComponentMetadataContext ctx) {
        def group = "com.graphql-java"
        ctx.details.with {
            if (id.group.startsWith(group)) {
                // declare that group's modules all belong to
                // the same virtual platform
                belongsTo("$group:virtual-platform:${id.version}")
            }
        }
    }
}

dependencies {
    components.all(GraphQLJavaAlignmentRule)
}
1
Thanks again!
One more question… is there a way to dynamically create an alignment rule, so I could have some sort of “alignGroup” function that I’d use like this:
Copy code
dependencies {
    components.all(alignGroup("com.graphql-java"))
    components.all(alignGroup("com.example.foo"))
    components.all(alignGroup("org.example.bar"))
}
?
e
you could make your rule work on multiple groups
l
We have several projects where I could imagine wanting to align different sets of groups. We have a plugin we share across projects, so I’d like to be able to define
alignGroup
in the plugin, and then have each project just have a one-liner for each group it wants to align. I’m not sure how to do that given that
components.all()
apparently takes a class rather than an instance or closure, though.
e
Copy code
class AlignGroupRule implements Action<ComponentMetadataRule> {
    String group
    @Override
    void execute(ComponentMetadataContext ctx) { ... }
}
dependencies {
    components.all(new AlignGroupRule(group: "com.graphql-java"))
🙌 1
but is there really a case where you recognize that a group could be aligned, but you don't want to?
l
Good point. Each of our projects, including the shared plugin, has its own git repo. The issue is if I’m working on project X, which depends on modules in “com.example.foo”, I don’t think I’d want to have to modify our shared plugin to align that group, and then let our CI publish it, and then switch each project to the updated plugin. At the same time, I’d rather not have the ~10 lines of boilerplate for the alignment rule in every project’s build file. That’s why I’m thinking it’d be nice to have the boilerplate in the plugin, and then each project can set up the alignment rules it needs based on its own dependencies.
Thanks for all of your help, @ephemient Unfortunately, some of my assumptions about graphql-java were incorrect. It looks like they don’t publish all of their modules in lockstep. Apparently they only publish graphql-java-extended-scalars on major versions. For example, for
com.graphql-java:graphql-java:17.2
one needs to use
com.graphql-java:graphql-java-extended-scalars:17.0
(the latter has no 17.2 version). So it looks like I’d need to somehow tell Gradle to round down the version of graphql-java that’s being pulled in transitively to determine which version of graphql-java-extended-scalars we want. I don’t know how to express that as an alignment rule, or if it’s even possible.
e
I don't think there's a good solution to this unless upstream publishes a proper platform (BOM or otherwise). you could maintain your own with https://docs.gradle.org/current/userguide/java_platform_plugin.html but it would not be automatic
l
Yeah, I suspected that the right answer was “upstream should publish a platform”. Thanks again!