AbstractDependencyMetadataRulesTest.groovy

Clone Tools
  • last updated a few minutes ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Remove `platform` dsl from constraint handler

These shortcuts define details of a dependency like attributes,

requested capabilities and 'endorse strict' status. These things

can not be defined on constraints. So these methods only cause

inconsistent behavior.

One can use constraints in combination with platforms like this to

control platform versions:

dependencies {

api platform("org:platform")

constraints {

api "org:platform:1.0"

}

}

    • -1
    • +0
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 12 more files in changeset.
Use a different 'shadow capability' for enforced platform

This allows both 'regular' and 'enforced' platform of the same

component to be selected. In order to make this work, support

for projects having shadow capability needed to be added.

    • -0
    • +2
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 12 more files in changeset.
Always apply all Category disambiguation rules

Before, parts of the platform disambiguation were only done when

using the 'java-platform' plugin. However, other consumers

may also require all rules (see #11091)

    • -1
    • +0
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 6 more files in changeset.
Revert "Revert "Merge branch 'release'""

This reverts commit 67b8bb8f18f854f45a2f5ec52cc9c8a25981e2f2.

This restores the merge attempt from earlier.

    • -1
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 66 more files in changeset.
Revert "Merge branch 'release'"

This reverts commit c7fdc455dcb9a8016af0ae9bc8b4c43fde1e2d06, reversing

changes made to 9f70d52b74dbc8c71381781b6c155474031b3cf8.

The changes need a wrapper as there are API changes. Reverting for now.

    • -1
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 66 more files in changeset.
Changes in Gradle Module Metadata loading

We no longer define any configurations, like default or the maven ones.

In the past, we still had these defined which allowed partial legacy

selection. But it made no sense since all these configurations would not

have any dependencies for example.

Fixes #10980

    • -1
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 16 more files in changeset.
Add test coverage for artifact selectors in GMM

    • -1
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 8 more files in changeset.
Introduce constraint inheritance API

    • -2
    • +2
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 40 more files in changeset.
Remove the singleton `NamedObjectInstantiator`. This is now available as a global service instead.

    • -2
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 13 more files in changeset.
Replace another usage of the `NamedObjectInstantiator` singleton with an injected service.

    • -7
    • +5
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 32 more files in changeset.
Inline org.gradle.testing.internal.util.Specification

    • -1
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 53 more files in changeset.
Introduce a `JAVA_API_JARS` usage

This commit introduces a new `JAVA_API_JARS` usage, mirror

to the `JAVA_RUNTIME_JARS` usage. This is both for consistency,

and to make sure that the `JAVA_API` and `JAVA_RUNTIME` usages

are limited to cases where the consumer doesn't care, or when

a producer doesn't have a more specific usage to provide.

This is, for example, the case for Java platforms. It's worth

noting than in case a producer mixes both "generic" usages

and "specific" usages, selection is likely to produce unexpected

results, because of disambiguation rules.

The Java disambiguation rule has been simplified and now

supports more cases.

    • -0
    • +2
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 37 more files in changeset.
Support requested capabilities on external dependencies

This commit adds support for having requested capabilities

part of the module component selector, for external dependencies.

This means that if a component is using Gradle metadata, we can

read requested capabilities and honor them during selection.

This reworks where requested capabilities are stored, and in

particular moves them to the `ComponentSelector`, making them

properly part of the identity of a dependency. As such, two

dependencies requiring two different variants by using distinct

capabilities will now properly appear as two different dependencies

in the dependency graph, instead of two variants of the same

dependency.

    • -2
    • +2
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 63 more files in changeset.
Initial support for optional features

This commit introduces initial support for optional features, by

implementing a way for a dependency declaration (currently *only* in

the DSL) to request variants of the target component that provide one

or more capabilities.

Previously to this change, selection was (simplified) done like this:

1. find the target component

2. select the variant of the target component which matches the requested

attributes

Now, selection introduces another step:

1. find the target component

2. filter variants by eliminating those which do not provide the requested

capabilities

3. select the variant in this list which matches the requested attributes

Several changes had to be implemented:

First, component metadata rules calling `addCapability` will now return

a component which capabilities _include_ the default capability.

Second, attribute filtering is done in a secondary step, which means that

if there are no variant matching the requested capabilities, we will immediately

fail.

    • -2
    • +2
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 58 more files in changeset.
Allow the services required by a given class to be queried prior to creating any instances of that class. Use this to allow `ArtifactTransformDependencies` to be injected into artifact transforms using any of the service injection patterns (that is, via a constructor or a getter).

    • -1
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 127 more files in changeset.
Replace most direct usages of `DirectInstantiator` with indirect usages via `InstantiatorFactory` or test fixtures instead. This means more consistent behaviour in unit tests because the objects under test will behave more similarly to how they do at runtime. This also allows the decision of how the instantiation should behave to live in as few places as possible, so this can be more easily evolved and contextualized.

    • -3
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 60 more files in changeset.
Split off value snapshotting and attributes related methods of TestUtil

    • -4
    • +6
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 64 more files in changeset.
Enable improved POM support by default

This commit makes the experimental flag `IMPROVED_POM_SUPPORT` the default.

The flag is still there for backwards compatibility but has effectively no

impact. As a consequence, the behavior of improved POM support is now the

default, which implies that:

- Maven dependencies packaged as `pom` or `jar` now have derived variants

(`compile` and `runtime`) and we properly choose between the variants based

on the consumer attributes

- platform dependencies using the `platform` and `enforcedPlatform` keywords

are enabled

Enabling improved POM support by default is a **breaking change**: there's

a risk that resolved dependencies is different, in particular because we

will now only include the `compile` dependencies of a POM file whenever the

consumer asks for the API variant. There are also some changes in the

dependency insight reports due to the use of attribute based matching instead

of configuration selection.

Last but not least, this commit is likely to introduce a small performance

regression due to attribute based selection.

    • -1
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 50 more files in changeset.
Import POM files as different variants

This commit implements solution 6 of #4422, by importing POM files

using different variants. By default, a POM file will be imported

as 6 different variants:

- 2 libraries (runtime and compile)

- 4 platforms (runtime and compile, regular and enforced)

This implies that a dependency on a BOM will now be intepreted as

a dependency on a library, whereas a dependency on a BOM expressed

using the `platform(...)` or `enforcedPlatform(...)` methods will

be interpreted as importing the platform component published at

the same coordinates.

This commit doesn't remove optional dependencies for Maven, but

reimplements how the dependencies are shuffled in different variants.

The dependencies found in a dependency management block are no

longer considered optional. Instead, they are properly marked as

constraints. However, they are only visible if using the experimental

flag, **and** using the platform variant.

    • -1
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 31 more files in changeset.
Omit excludes for Maven optional dependencies

For BOM import support, when a <dependencyManagement> entry has a declared <exclusion>,

we apply this exclusion globally whenever the target module is resolved, regardless of

the path to the module. However, this behaviour is not desired for <optional> dependencies,

and these could not be distinguished from <dependencyManagement> entries after the POM was parsed.

With this change, we retain a 'type' attribute for all dependencies parsed from a Maven POM

file. This allows us to omit any exclusions that are defined for a dependency declared with

<optional>, while retaining them for <dependencyManagement> entries.

    • -1
    • +3
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 8 more files in changeset.
Implement enforced platforms via variants instead of component metadata rules

This commit replaces the component metadat rules implementation with

proper variant based matching. It introduces a new attribute, the component

category, which can currently be either a library or a platform. By default,

components are assumed to be libraries.

    • -1
    • +9
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 14 more files in changeset.
Rename 'DependencyMetadata.isPending()` -> `isConstraint()`

    • -3
    • +3
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 22 more files in changeset.
Retain separate versions for 'strictly' and 'prefers'

Previously, a `strictly` version constraint was translated into a separate

'prefer' and 'reject' constraint: this is how it was processed internally,

as well as how it was represented in a `.module` file.

With this change, strict version constraints are logically retained as a

first class version constraint:

- `.module` files can have versions declared with `strictly`

- Strict constraints are only translated to a reject version selector

as part of resolution (not when parsing the constraint)

    • -1
    • +3
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 25 more files in changeset.
Fix unit test so that assertions are actually tested

    • -10
    • +10
    ./AbstractDependencyMetadataRulesTest.groovy
Refactor ModuleResolveMetadata

Reorganize code in packages, move serialization related code closer to

classes to reduce need of public methods.

    • -0
    • +2
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 79 more files in changeset.
Normalize `ModuleIdentifier`

This commit reworks the `ComponentModuleIdentifier`/`ComponentModuleSelector`/`ModuleVersionSelector`

classes to use `ModuleIdentifier` under the hood, instead of storing denormalized strings. This has

the advantage that we can reduce the use of the module identifier factory, which is called very

often during dependency resolution. Sharing instances reduces the need for conversions, and makes

comparisons faster.

    • -5
    • +6
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 164 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
    • +1
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 53 more files in changeset.
Intern strings when reading module metadata from cache

Dependency resolution of large dependency graphs involves a significant

number of comparisons of strings(group, artifact, version, ...). Most of

those come from the module metadata cache, and even if we use hashmaps,

we still need to perform `equals` comparisons on strings, when in most

of the cases they should be identical. This commit takes advantage of

knowing that to add a cost when we read module metadata (interning), but

realizing that the debt is paid when comparing strings during resolution.

The interner is build scoped (in order to avoid memory leaks), thread-safe,

and shared with the dependency notation converter, so that module selectors

created from strings found in the build scripts are using the same strings

as the ones from the module metadata cache.

Ideally, we should also do this for the strings used during parsing.

    • -2
    • +3
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 17 more files in changeset.
Read dependency attributes in Gradle module metadata

This commit adds support for parsing dependency attributes in Gradle module metadata.

It is not yet making use of that information, it's only making sure that the parser

is able to parse and propagate it. It doesn't touch the serializer either, which is

going to be done in a separate commit.

Module metadata file version has been bumped to 0.4 as part of this work.

    • -2
    • +2
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 17 more files in changeset.
Honor constraint attribute during selection

This commit makes sure that attributes from all selectors are used during

selection, including the attributes from constraints. It does not, however,

make sure that those attributes are consistent (compatible).

    • -1
    • +2
    ./AbstractDependencyMetadataRulesTest.groovy
  1. … 13 more files in changeset.