-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't cast public interface MutableVersionConstraint
to internal internal implementations (DefaultMutableVersionConstraint
).
#22557
Comments
Could you please explain to us what your use case is? |
For doing a custom implementation of Optional<Provider<MinimalExternalModuleDependency>> findLibrary(String alias);
VersionConstraint getVersionConstraint(); If you try to just implement If #22718 is fixed, this issue becomes less relevant. |
Can you explain why you are implementing a custom version catalog? |
Mostly working around issues like these:
But implementing public interfaces is also useful for making You can avoid these types of issues if you wrap the interfaces with internal impls instead of casting them to internal impls, to avoid these type of issues. As noted above, wrapping instead of casting solves this issue:
|
I want to implement a custom implementation of the
VersionCatalog
interface, I may also need to also implementMinimalExternalModuleDependency
andVersionConstraint
But this causes error like this:
This is because gradle is casting the public interface (
MutableVersionConstraint
) to an internal implementation (org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint
) here:gradle/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/dependencies/AbstractExternalModuleDependency.java
Line 54 in c267a7d
It defeats the purpose of the
interface
if you assume that it is always an instance ofDefaultMutableVersionConstraint
(internal API)If you change that line to:
that should fix it.
The text was updated successfully, but these errors were encountered: