ComponentAttributeMatcherTest.groovy

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Desugar producer attribute if the requesting attribute is desugared (#11372)

This can be the case if an attribute on a dependency is published

and the resolved target of the dependency is a local project.

For example, a published platform dependency to a local java-platform

project.

We support 'Named' and 'Enum' for desugaring as that are the only

non-primitve types we currently allow to be published in Gradle

Module Metadata.

    • -0
    • +104
    ./ComponentAttributeMatcherTest.groovy
  1. … 3 more files in changeset.
Desugar producer attribute if the requesting attribute is desugared

This can be the case if a attribute on a dependency is published

and the resolved target of the dependency is a local project.

For example, a published platform dependency to a local java-platform

project.

    • -0
    • +32
    ./ComponentAttributeMatcherTest.groovy
  1. … 3 more files in changeset.
Desugar producer attribute if the requesting attribute is desugared

This can be the case if a attribute on a dependency is published

and the resolved target of the dependency is a local project.

For example, a published platform dependency to a local java-platform

project.

We support 'Named' and 'Enum' for desugaring as that are the only

non-primimitve types we currently allow to be published in Gradle

Module Metadata.

    • -0
    • +104
    ./ComponentAttributeMatcherTest.groovy
  1. … 3 more files in changeset.
Desugar producer attribute if the requesting attribute is desugared

This can be the case if a attribute on a dependency is published

and the resolved target of the dependency is a local project.

For example, a published platform dependency to a local java-platform

project.

    • -0
    • +32
    ./ComponentAttributeMatcherTest.groovy
  1. … 3 more files in changeset.
Desugar producer attribute if the requesting attribute is desugared

This can be the case if a attribute on a dependency is published

and the resolved target of the dependency is a local project.

For example, a published platform dependency to a local java-platform

project.

We support 'Named' and 'Enum' for desugaring as that are the only

non-primimitve types we currently allow to be published in Gradle

Module Metadata.

    • -0
    • +104
    ./ComponentAttributeMatcherTest.groovy
  1. … 3 more files in changeset.
Remove utilisation of *-jars usage values

    • -15
    • +15
    ./ComponentAttributeMatcherTest.groovy
  1. … 55 more files in changeset.
Remove utilisation of *-jars usage values

    • -15
    • +15
    ./ComponentAttributeMatcherTest.groovy
  1. … 55 more files in changeset.
Remove utilisation of *-jars usage values

    • -15
    • +15
    ./ComponentAttributeMatcherTest.groovy
  1. … 55 more files in changeset.
Remove utilisation of *-jars usage values

    • -15
    • +15
    ./ComponentAttributeMatcherTest.groovy
  1. … 56 more files in changeset.
Remove utilisation of *-jars usage values

    • -15
    • +15
    ./ComponentAttributeMatcherTest.groovy
  1. … 56 more files in changeset.
Remove utilisation of *-jars usage values

    • -15
    • +15
    ./ComponentAttributeMatcherTest.groovy
  1. … 55 more files in changeset.
Remove utilisation of *-jars usage values

    • -15
    • +15
    ./ComponentAttributeMatcherTest.groovy
  1. … 56 more files in changeset.
Remove utilisation of *-jars usage values

    • -15
    • +15
    ./ComponentAttributeMatcherTest.groovy
  1. … 56 more files in changeset.
Remove utilisation of *-jars usage values

    • -15
    • +15
    ./ComponentAttributeMatcherTest.groovy
  1. … 56 more files in changeset.
Improve attribute disambiguation rule

This commit implements a smarter strategy for attribute disambiguation,

whenever _some_ variants have missing information. By missing information,

we mean that some variants carry at least one extra attribute, and others

do not. Because we consider the absence of an attribute as a compatible

match, BUT that when we disambiguate we only consider the variants which

actually provided a value, there was no way to prefer a match which

is "closer" to the request.

See #6747

    • -64
    • +134
    ./ComponentAttributeMatcherTest.groovy
  1. … 1 more file in changeset.
Split off value snapshotting and attributes related methods of TestUtil

    • -2
    • +2
    ./ComponentAttributeMatcherTest.groovy
  1. … 64 more files in changeset.
Test that disambiguation rule gets non-null candidate values

    • -0
    • +28
    ./ComponentAttributeMatcherTest.groovy
Avoid unnecessary computation of extra attributes

The attributes set which are compared are almost always the same, yet

we allocate and compute them very often, leading to a waste of memory

and CPU time. This commit takes advantage of the fact we know the

attribute set is reduced to cache it and avoid allocation.

    • -0
    • +6
    ./ComponentAttributeMatcherTest.groovy
  1. … 4 more files in changeset.
Revert "Revert "Speed up attribute matching""

    • -0
    • +37
    ./ComponentAttributeMatcherTest.groovy
  1. … 14 more files in changeset.
Revert "Speed up attribute matching"

    • -37
    • +0
    ./ComponentAttributeMatcherTest.groovy
  1. … 14 more files in changeset.
Improve attribute matching performance

Only look at extra attributes (that were not requested)

if there was no match after compatibility checking and

disambiguating the requested attributes. This avoids

creating the full attribute set in most cases.

As a result the schema no longer needs to provide a full

list of attributes, which removes some complexity.

This change also removes the adaptive sizing of the matching

table, since it is now so small that being adaptive doesn't

improve performance, but actually makes it worse due to the

added CPU cycles for finding the right slot in the array.

    • -0
    • +37
    ./ComponentAttributeMatcherTest.groovy
  1. … 6 more files in changeset.
Make AttributeSelectionSchema more efficient

For compatibility checks, only create the Details

object if the checked values are different and there

are any compatibility rules.

For disambiguation, if no rule expresses an opinion,

just return the original candidate set instead of

constructing a copy. If there are no rules, don't

create the details object.

    • -21
    • +15
    ./ComponentAttributeMatcherTest.groovy
  1. … 19 more files in changeset.
Use the attributes factory to create mutable containers in addition to immutable containers, to decouple clients from the mutable container implementation and the things it may need.

    • -3
    • +3
    ./ComponentAttributeMatcherTest.groovy
  1. … 10 more files in changeset.
Changed attribute matching to consider two attributes with the same name as the _same_ attribute, failing if the producer and consumer values have types that are not compatible. Previously, two attributes with the same name and different types would be considered distinct attributes, leading to some confusing behaviour when types are mismatched.

    • -0
    • +31
    ./ComponentAttributeMatcherTest.groovy
  1. … 2 more files in changeset.
Retain the value of a variant attribute as an isolated value, rather than retaining the original value. Attribute values are snapshot at the point where the attribute is registered and are isolated from further changes to the original value.

This change allows attribute matching to more safely happen in parallel and means that attribute values can behave more consistently with other features that use isolated and snapshot values, such as task inputs or artifact transforms.

    • -2
    • +2
    ./ComponentAttributeMatcherTest.groovy
  1. … 18 more files in changeset.
Added `MultipleCandidatesDetails.getConsumerValue()` to allow an attribute disambiguation rule to select the best match based on the consumer's value, if any.

    • -2
    • +46
    ./ComponentAttributeMatcherTest.groovy
  1. … 7 more files in changeset.
Changed configuration selection during dependency resolution so that when the consumer defines some attributes the matching falls back to the `default` configuration only when the target component has no configurations with attributes attached. Otherwise, the `default` configuration is treated the same way as all other configurations and treated as a candidate only when it has attributes attached.

Previously, the `default` configuration was used when there were no _matching_ configurations with attributes attached in the target component.

The behaviour is unchanged when the consumer or target component do not define any attributes or the `default` configuration is explicitly selected.

    • -20
    • +62
    ./ComponentAttributeMatcherTest.groovy
  1. … 7 more files in changeset.
Changed variant attribute matching to prefer variants whose value for a particular attribute is the same as the consumer value, over those variants whose value is different to but compatible with the consumer value. That is, added a hard-coded rule to say "prefer the requested value over all others" when disambiguating matches.

    • -1
    • +1
    ./ComponentAttributeMatcherTest.groovy
  1. … 6 more files in changeset.
Changed attribute matching so that a missing attribute is always considered compatible.

`CompatibilityRuleChange.assumeCompatibleWhenMissing()` is now a no-op and will be removed shortly.

    • -126
    • +49
    ./ComponentAttributeMatcherTest.groovy
  1. … 11 more files in changeset.
Changed attribute matching to chain the producer's rules after the consumer's rules, rather than stopping at the end of the consumer's rules. This allows the consumer to reuse the producer's rules but override certain decisions, and it allows the producer to add new values for an attribute that the consumer knows about which are compatible with the consumer value.

    • -22
    • +121
    ./ComponentAttributeMatcherTest.groovy
  1. … 23 more files in changeset.