Skip to content

Conversation

melix
Copy link
Contributor

@melix melix commented Jun 4, 2021

This PR removes the restriction that you cannot have an alias which is both an accessor for a dependency (or version or bundle) and a subaccessor for other dependencies. This is now allowed:

implementation libs.top
implementation libs.top.bottom

Fixes #17170

melix added 2 commits June 4, 2021 09:12
In previous releases, it wasn't possible to declare a version catalog alias which was an
intermediate node, but also provided a value. For example, this was invalid (using TOML
but the API had the same restrictions):

   [libraries]
   top="org:foo:1.0"
   top.bottom="org:bar:1.0"

The reason is that we need the leaves to be providers and there's no custom implementation
of a provider for dependency notations (custom implementations are expensive to maintain
and should be avoided).

To workaround this problem, this commit introduces an interface, `ProviderConvertible`,
which is implemented by intermediate nodes which also provide a value. This interface
provides a single method, `asProvider()`, which is transparently called by Gradle when
such a notation is added as a dependency:

    implementation(libs.top) // libs.top implements ProviderConvertible

so this is equivalent to writing:

    implementation(libs.top.asProvider())

And accessing the leaf is possible as before using:

    implementation(libs.top.bottom)

Fixes #17170
@melix melix added @core Issue owned by GBT Core in:dependency-version-catalog labels Jun 4, 2021
@melix melix added this to the 7.2 RC1 milestone Jun 4, 2021
@melix melix self-assigned this Jun 4, 2021
melix added 2 commits June 4, 2021 10:47
This commit fixes a null pointer exception whenever a catalog references aliases
using different separators than what was expected. This was accidentally found when
fixing the nested alias structure, which in some cases may use the wrong alias because
it builds paths using `.` instead of what would be declared in a catalog.

Now it doesn't matter how the client asks for an alias/bundle/version: it is always
normalized when building the catalog or querying it.
So that the written aliases are always normalized to the TOML format (using `-` instead of `.`).
@gradle gradle deleted a comment from melix Jun 4, 2021
@gradle gradle deleted a comment from melix Jun 4, 2021
@melix melix requested a review from ljacomet June 4, 2021 12:17
Copy link
Member

@ljacomet ljacomet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Can you also add something to the release notes for these changes?

@melix melix requested a review from pioterj as a code owner June 8, 2021 08:14
@gradle gradle deleted a comment from melix Jun 8, 2021
@gradle gradle deleted a comment from melix Jun 8, 2021
@gradle gradle deleted a comment from melix Jun 8, 2021
@gradle gradle deleted a comment from melix Jun 8, 2021
bot-gradle added a commit that referenced this pull request Jun 8, 2021
Remove restriction on subgroups in version catalogs
@gradle gradle deleted a comment from melix Jun 8, 2021
@bot-gradle
Copy link
Collaborator

Pre-tested commit build failed.

@bot-gradle
Copy link
Collaborator

OK, I've already triggered a build for you.

@blindpirate
Copy link
Collaborator

@bot-gradle test and merge

@gradle gradle deleted a comment from melix Jun 8, 2021
@bot-gradle
Copy link
Collaborator

Your PR is queued. See the queue page for details.

@bot-gradle
Copy link
Collaborator

OK, I've already triggered a build for you.

@bot-gradle bot-gradle merged commit ca2c24a into master Jun 9, 2021
@blindpirate blindpirate deleted the cc/dm/remove-catalog-subgroup-restriction branch July 16, 2021 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better error message for typed deps from a TOML file.

4 participants