This message was deleted.
# community-support
s
This message was deleted.
v
You should not use a dependency resolve rule, but a metadata rule, where you then "fix" the artifacts to want to have.
m
Ah yes sounds like this is what I want
Looks like it, I'll dig ⛏️. Thanks for the pointer, as always 🙏
👌 1
Actually dependency substitution
withoutArtifactSelectors()
kindof works (although it's most likely less precise than patching the offending module):
Copy code
configurations.all {
    resolutionStrategy.eachDependency {
        if (requested.group == "androidx.datastore" && requested.module.name =="datastore-preferences") {
            artifactSelection {
                this.withoutArtifactSelectors()
            }
        }
    }
}
🤷‍♂️ 1
Alright, I could make it works with something like so:
Copy code
components {
        withModule("com.google.firebase:firebase-sessions") {
            allVariants {
                withDependencies {
                    val deps = this.toList()
                    removeAll { true }
                    addAll(deps.map {
                        if (it.name == "datastore-preferences") {
                            DirectDependencyMetadataImpl("androidx.datastore","datastore-preferences", "1.1.0-alpha04")
                        } else {
                            it
                        }
                    })
                }
            }
        }
    }
v
I'm not sure that is a good idea, as you use an internal class. Did it not work to modify the artifacts of the datastore module?
m
I think what I want is to modify the
artifactSelectors
v
What I imagined is something like
Copy code
components {
    withModule("androidx.datastore:datastore-preferences") {
        allVariants {
            withFiles {
                removeAllFiles()
                addFile("datastore-preferences-1.1.0-alpha04.jar")
            }
        }
    }
}
👀 1
m
Problem is on
firebase-session
that is a POM module that declares an .aar dependency on
datastore-preference
v
But, yeah, if the
firebase-session
dependency is the wrong one, then probably more
Copy code
components {
    withModule("com.google.firebase:firebase-sessions") {
        allVariants {
            withDependencies {
                removeIf {
                    (it.group == "androidx.datastore") && (it.name == "datastore-preferences")
                }
                add("androidx.datastore:datastore-preferences:1.1.0-alpha04")
            }
        }
    }
}
💯 1
1
m
Ah yes, much better 👍
Thanks!
v
Or maybe
Copy code
components {
    withModule("com.google.firebase:firebase-sessions") {
        allVariants {
            withDependencies {
                find {
                    (it.group == "androidx.datastore") && (it.name == "datastore-preferences")
                }?.attributes {
                    attribute(/* set the artifact type to jar */)
                }
            }
        }
    }
}
Not sure if the latter works
m
I don't think attributes would work here? From what I understand because it's a POM module, it's about extensions not attributes?
firebase-sessions
has no module file at all
v
POMs are to a certain degree translated to attributes. Not sure whether this will work or whether it would even work with GMM
👍 1
m
Well removing and adding the dependency works perfectly, I'll stick with that and keep attributes exploration for next time 😄
👌 1