I have a configuration that extends another one, h...
# dependency-management
i
I have a configuration that extends another one, however the child configuration has additional attributes that not all dependencies declared in the parent configuration have. Currently, Gradle crashes when it cannot find an artifact for the child configuration. However, I would prefer Gradle to ignore dependencies declared in the parent configuration that cannot satisfy the child configuration. Or, said another way, I want the child configuration to depend on anything declared in the parent configuration but only if they have a variant that satisfies the child configuration's attributes. Is this possible?
v
Use an artifact view. It should exactly behave like you want. You can even set it to
lenient
which would then additionally ignore any errors, so also things like download problems or connection problems.
i
Reading the javadoc and it sounds exactly like what I'm searching for. Do you know if: • I can have a regular configuration extend from a view? • Is there any more documentation than the page I linked above?
v
No, extending a configuration from an artifact view makes exactly 0 sense šŸ™‚
Extending configuration A from a configuration B means that all dependencies declared for B are like they were also declared for A. An artifact view is a view on the artifacts of a configuration.
And yes, there are other documentation pages or samples like for example https://docs.gradle.org/current/userguide/artifact_resolution.html#sec:customizing-artifact-selection
i
What would be your preferred solution for "some dependencies in this configuration have an additional variant, by default I want to download the variants with a specific attribute in another local directory, but I still want the user to be able to include additional dependencies specifically for that directory, or also exclude some that were added by the default rule mentioned above"? I was thinking "child configuration which defaults to the real configuration, ignoring dependencies that don't have that variant", but maybe there's another idea altogether?
v
From the information you gave, I right now also do not have a better idea, but it might also be depending on more gory details. šŸ¤·ā€ā™‚ļø