ResolveTestFixture.groovy

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Rename inheritStrictVersions() -> endorseStrictVersions() (#10755)

This name change more clearly communicates the semantics of the

feature from a users point of view.

This commit also removes all mentions of 'inheriting' AND 'forSubgraph'.

There have been some leftovers in documentation/comments that

would have been misleading in the future. To make sure we catch all,

this also updates all variable/method/package names.

  1. … 70 more files in changeset.
Add integration tests for subgraph version constraints

  1. … 2 more files in changeset.
Add strict reasons check to resolve fixtures

Add BY_ANCESTORS selection reason

  1. … 2 more files in changeset.
Add support for 'forSubgraph' to metadata test fixtures

  1. … 7 more files in changeset.
Add support for Java test fixtures

This commit introduces conventional support for _test fixtures_

in the Java ecosystem.

The `java` extension, available when applying either the `java`

or `java-library` plugins, now adds a couple of methods:

- `enableTestFixtures`, which will create an additional source

set for test fixtures

- `usesTestFixturesOf`, which declares that this project makes

use of the test fixtures of another project or external module

This feature builds on top of the existing feature variant

infrastructure, which means that:

- test fixtures are published (as optional dependencies in Maven,

as variants with Gradle metadata)

- test fixtures have a conventional capability

The capability for test fixtures is `test-fixtures`, so it means

that if the project has a name `foo`, then its test fixtures

would be published with a capability name of `foo-test-fixtures`.

Test fixtures expose an API and an implementation, available

through the `testFixturesApi` and `testFixturesImplementation`

configurations.

When test fixtures are enabled, the test fixtures API automatically

gets a dependency onto the main component (aka `src/main/java`).

  1. … 9 more files in changeset.
Change ResolveTestFixture to default to 'runtimeClasspath'

  1. … 1 more file in changeset.
Fix Groovy/Java library compatibility

This commit fixes the Groovy + Java Library compatibility,

by making sure that if, and only if, the Java Library is

applied on a project that also applies the Java Library

plugin, then the correct variants is selected.

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

  1. … 37 more files in changeset.
Test for selecting multiple variants of a local project

This commit adds a test showing we can use variant-aware dependency management

to select 2 variants of the same project.

This test is not intended to be an example how to expose test fixtures,

it's only there for coverage.

  1. … 4 more files in changeset.
Support depending on multiple variants of the same component

This commit changes the resolution engine so that it is possible

to resolve multiple variants of the same component when using

variant-aware dependency management.

Before, in order to have 2 dependencies on the same component

but using different variants, one had to use explicit configuration

dependencies. Now, with this change, it is possible to have

two dependencies on the same component, but with different attributes.

Those components would resolve to different variants.

Special treatment is applied when attributes are declared on constraints:

in this case, we _merge_ the constraint attributes, and make sure that

the edge is computed using the merged attributes. Should they be

incompatible, the build would fail as before.

  1. … 29 more files in changeset.
Tweak the output produced by `TreeFormatter`.

  1. … 36 more files in changeset.
Use repository content filtering when selecting dynamic versions

This commit fixes an issue with content filtering, which led to versions

being silently ignored because we were listing versions, _then_ filtering.

Instead, this commit makes sure we actually only return versions which

do participate in the repository.

  1. … 6 more files in changeset.
Differentiate between dependency and constraint edges in `ResolveTestFixture`

  1. … 8 more files in changeset.
Simplify verification of constraints in `ResolveTestFixture`

  1. … 3 more files in changeset.
Track unmatched versions in SelectorState

Previously, when resolving a selector we were registering the unmatched

versions at the component level. The `ComponentState` would keep a map

of selector -> unmatched versions, which would later be reconnected to

the original selector.

With this change, the unmatched versions are kept with the `SelectorState`

until required to form a component selection reason. This simplifies the

logic and reduces the number of collection copies required.

  1. … 11 more files in changeset.
Implement variant derivation strategy

This commit changes how Maven metadata is derived into variants. Now we will

only derive variants if the Java plugin is applied (the "base Java" plugin).

This is implemented via a variant derivation strategy, and allows fixing

the problem that a native component is unlikely to find sense in the derivation

of Java variants. This fixes a bug where the native plugins wouldn't be able

to consume native libraries published on Maven repositories, without Gradle

metadata.

  1. … 43 more files in changeset.
Add support for forcing a platform using a constraint

This commit adds support for aligning a platform to a forced

version using a constraint. Similarly to the dependency case,

this allows forcing the platform, but also implies that the

members of the platform are _also_ forced.

  1. … 6 more files in changeset.
Update Nebula recommender plugin version for smoke test

The ResolveTestFixture needed a fix to handle selection reasons with a

newline character.

The test assertions have changed as 'selected by rule' now requires

additional message.

Fixes #6177

  1. … 2 more files in changeset.
Consistently report conflict resolution

This commit refactors how conflict resolution selection reasons are handled, in order to:

- collect the list of versions which participated in conflict resolution

- report a single conflict resolution cause when conflicts are resolved several times for the same module

- consistently report module replacement rules as rules, not conflict resolution. Before this change,

a module replacement was reported as both a conflict and a rule

  1. … 29 more files in changeset.
Collect unmatched dependencies too

Without this change, it is not possible to know which versions Gradle

considered for a dynamic range, unless it's rejected by a rule or by

attribute matching.

  1. … 19 more files in changeset.
Use register() over createLater() in all built-in plugins

  1. … 9 more files in changeset.
Associate rejected versions with their constraint or rule

This commit reworks the mapping between rejected versions and

version selectors, so that we can make the difference between

a version which was rejected by a selector (regular or constraint)

or a rule. Then the dependency insight report can properly show

what versions were rejected in which context.

  1. … 18 more files in changeset.
Bridge tasks into software mode lazily

Only initialize the software model bridging if the user

either uses the `model {}` block or explicitly applies

a rule-based plugin.

Placeholder tasks are now implemented in the task container

directly instead of using the software model. They are also

deprecated as they add a lot of complexity for no gain beyond

what `createLater {}` already offers.

  1. … 29 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. … 13 more files in changeset.
Use dependency attributes when selecting variants of a single component

This commit makes sure that attributes defined on a dependency are used whenever

a component has multiple variants, and we need to select one of the variants.

However, this doesn't work yet when an attribute on a dependency overrides the

consumer attributes (the attributes defined on a configuration). In this case,

we will rightfully select the variant, but as soon as we try to get the artifacts

of this variant, we will fail, because we're selecting _again_ the variant, but

the only thing we have at this point is the selected component and the consumer

attributes (we have lost the dependency attributes).

  1. … 10 more files in changeset.
Separate Dependency Constraint and Dependency declarations (#4255)

The interfaces for declaring these two different things were

coupled in the initial implementation - to reuse all functionality

based on the Dependency interface directly. This interface is used

internally to pass dependency declarations through the resolution

process. However, this is only due to remembering the first

level dependencies for the "old" results API

(Configuration.resolvedConfiguration()).

These implementation specifics should not bleed into the API.

A dependency declaration defines a *requirement*:

I require module/project X

A dependency constraint defines a *constraint*:

If I must use X, I can only work with versions matching the constraint

Only if we look at external dependencies, constraints and external dependencies

share the ability to declare a *version constraint*. Therefore, both now

extend ModuleVersionSelector.

Now, dependency constraints are removed as "first level dependencies"

from the result. This is fine as the dependency itself is still in the

result graph - when there is a constraint, there is always at least one other

edge.

  1. … 33 more files in changeset.
Fix ResolveTestFixture so that it correctly reports missing nodes

Test timestamped identifier for resolved snapshots

  1. … 4 more files in changeset.
Improve `ResolveTestFixture` to support multiple reasons

The resolve test fixture only took the last "description" into consideration. This makes it hard to write tests for custom dependency

reasons. Also, the output of the comparison wasn't very developer friendly, because it was showing the internal, stringy, representation

of the dependency graph nodes.

This commit improves everything by not relying on string comparisons anymore to compare the components. Edges are still compared using

strings, but it already makes things much easier to reason about.