AbstractConfigurationAttributesResolveIntegrationTest.groovy

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Revalidate that selected configurations match the requested attributes

This commit changes the behavior of dependency resolution in case a selected configuration doesn't match

the requested attributes. It could happen in two cases:

- in case no matching configuration is found, we fallback to the `default` configuration, which could have attributes

that did *not* match (it was part of the selection, but in the end since no configuration was matching, it was selected

anyway).

- in case an explicit configuration was chosen. In that case, we didn't check that the selected configuration matched

the consumer attributes.

Error messages have been improved as part of this story. It's worth noting that this commit does NOT change the

selection algorithm, and we will always fallback to the `default` configuration in case no match is found. The only

thing it does is really revalidating that this fallback is compatible.

See gradle/performance#233

    • -1
    • +66
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 5 more files in changeset.
Improve error messages in case of ambiguous matches

This commit adds the target component name in the error message, making it clearer where the problem is.

    • -6
    • +6
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 5 more files in changeset.
Merge `optionalOnConsumer` and `optionalOnProducer`

This commit merges the implementations of `optionalOnConsumer` and `optionalOnProducer`

rules into a single `assumeCompatibleWhenMissing()` call. Note that the semantics of

"missing" here are slightly different from the semantics of missing on `AttributeValue`

because it will apply equally to both unknown and missing attributes.

    • -14
    • +13
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 7 more files in changeset.
Rename `configureMatchingStrategy` to `attribute` and add a no configure action variant

    • -13
    • +13
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 15 more files in changeset.
Remove the need for special handling of partial matches

Partial matches are no longer a special case with this commit. Instead, the

strategy defines what to do in case an attribute is missing or unknown, in

both the consumer and producer side. This allows richer matching strategies,

where an attribute can become optional, instead of being systematically

optional.

This changes the default strategy, by requiring an explicit call to

`optionalOnXXX` to make an attribute missing relevant or not.

    • -3
    • +67
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 17 more files in changeset.
Make sure we don't fallback on the `default` configuration if it's not consumable

Before this commit, if we didn't find any match, we unconditionnaly felt back to the `default`

configuration, even if it wasn't consumable. Now, selection will honor the `canBeConsumed`

flag in both cases: explicit configuration selection *and* fallback.

    • -0
    • +50
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 4 more files in changeset.
Fix partial matching of attributes

There was a problem in the algorithm when a configuration was partially matching,

but one of its attributes wasn't compatible. Then it was considered a partial match

but it shouldn't have.

    • -0
    • +57
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 2 more files in changeset.
New attempt to fix tests on Windows

    • -14
    • +23
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 1 more file in changeset.
Fix tests on Windows

    • -6
    • +8
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 1 more file in changeset.
Improved error messages in case of ambiguous matchs

This commit provides a better error message in the case we cannot choose between multiple configurations.

It will display an error message that gives the expected values, the missing attributes, and the attributes

that were found but not requested.

    • -11
    • +51
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 2 more files in changeset.
Handle the case where an attribute is relevant to the consumer but not to the producer

This commit introduces the notion of "partial matches", which are allowed whenever an attribute

is relevant to a consumer, but not to a producer. For example, a consumer wants to depend on

a library with `flavor: 'free', buildType:'debug'` but the consumer only cares about flavors.

In that case, we have a partial match. This commit changes the algorithm to take that into

account, and makes sure that complete matches are preferred over partial matches.

    • -11
    • +63
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 2 more files in changeset.
Add integration test cases for the use cases we want to cover in better attribute matching

    • -2
    • +185
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 2 more files in changeset.
Add strongly typed variant of configuration attributes resolution integration test

This test adds a variant of the configuration attributes resolving integration test that

makes use of strongly typed attributes instead of the basic string version. To do this,

tests were extracted into a super class and both variants of the test provide the notation

for attributes.

    • -0
    • +1096
    ./AbstractConfigurationAttributesResolveIntegrationTest.groovy
  1. … 4 more files in changeset.