DefaultAttributesSchemaTest.groovy

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Replace most usages of `NamedObjectInstantiator.INSTANCE` with injection of a global service instead. This allows the instantiator to be contextualized, for example to handle caching of the generated types.

  1. … 25 more files in changeset.
Replace most usages of `NamedObjectInstantiator.INSTANCE` with injection of a global service instead. This allows the instantiator to be contextualized, for example to handle caching of the generated types.

  1. … 27 more files in changeset.
Replace most usages of `NamedObjectInstantiator.INSTANCE` with injection of a global service instead. This allows the instantiator to be contextualized, for example to handle caching of the generated types.

  1. … 27 more files in changeset.
Replace most usages of `NamedObjectInstantiator.INSTANCE` with injection of a global service instead. This allows the instantiator to be contextualized, for example to handle caching of the generated types.

  1. … 27 more files in changeset.
Split off value snapshotting and attributes related methods of TestUtil

  1. … 64 more files in changeset.
Enforce isolation of ComponentMetadataRule

This means that passed in parameters must be snapshotable as defined by

the ValueSnapshotter

Added support for Attribute to ValueSnapshotter

  1. … 53 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.

    • -62
    • +18
    ./DefaultAttributesSchemaTest.groovy
  1. … 19 more files in changeset.
Make attribute matching more efficient

Replace the many nested objects, sets and maps

with a single array of matching values and a BitSet

tracking which candidates are still "alive".

This significantly reduces memory usage of attribute

matching and makes it run much faster.

    • -33
    • +20
    ./DefaultAttributesSchemaTest.groovy
  1. … 7 more files in changeset.
Removed validation from `Attribute.of()`, as the set of valid types is a function of how and where the attribute is used. Instead, moved the validation to `AttributeContainer.attribute()` to accept anything that can be made isolated.

Added some functional test coverage for how attribute values behave.

    • -34
    • +4
    ./DefaultAttributesSchemaTest.groovy
  1. … 5 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.

  1. … 18 more files in changeset.
Make the verification of `Named` immutables stricter

This commit addresses review feedback: the check on `Named` was only checking that the user provided a type

extending `Named`, but they could very well provide a concrete type, which wouldn't be immutable. By making

sure we can only use an interface, then users can only use `Named` types which are actually not instantiable

directly. This won't prevent from passing a value which is a concrete type, but it will prevent declaring

attributes of mutable types.

    • -12
    • +28
    ./DefaultAttributesSchemaTest.groovy
  1. … 3 more files in changeset.
Limit the type of attributes to types we can make immutable

This commit restricts the possibilities of custom types for attributes. Since attributes are used in various

places, potentially different classloaders or even different process, we need a stable way to make them

both snapshottable and serializable. This commit is the first step, by making it impossible to create attributes

with arbitrary types.

Types that we support include:

- scalar types, which are primitive types (and their wrappers), `File` or `String` (aka, known immutables)

- a type extending `Named`, in which case it is expected to create values using the `ObjectFactory`

- an enum

- an array of the above (arrays are not immutable, but we can create immutable values out of arrays)

Some tests had to be adjusted, because they didn't match those constraints. Future work will include possibilities

to include richer types.

    • -26
    • +93
    ./DefaultAttributesSchemaTest.groovy
  1. … 5 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.

    • -14
    • +14
    ./DefaultAttributesSchemaTest.groovy
  1. … 7 more files in changeset.
Changed attribute value disambiguation to allow a rule to select a candidate that is not the same as the requested, for example when a general value is requested ("give me the java api") and the rule selects a more specialized value ("use the java api classes").

    • -29
    • +128
    ./DefaultAttributesSchemaTest.groovy
  1. … 1 more file 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.

    • -7
    • +44
    ./DefaultAttributesSchemaTest.groovy
  1. … 6 more files in changeset.
Fixed implementation of `AttributeMatcher.isMatching()` in the presence of compatibility rules. This is only used to construct error messages, rather than matching configurations or variants.

  1. … 1 more file 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.

    • -26
    • +0
    ./DefaultAttributesSchemaTest.groovy
  1. … 11 more files in changeset.
Shuffled around the API for `AttributeSchemaInternal` so that the logic that constructs various error messages uses `AttributeMatcher`, which is the same API used for selection, rather than `AttributeSelectionSchema` which is used in the internals of attribute matching.

    • -8
    • +36
    ./DefaultAttributesSchemaTest.groovy
  1. … 10 more files in changeset.
Moved some classes from 'core' to 'dependencyManagement' to live with related classes.

    • -0
    • +225
    ./DefaultAttributesSchemaTest.groovy
  1. … 29 more files in changeset.