Skip to content

Conversation

jvandort
Copy link
Member

@jvandort jvandort commented Oct 7, 2025

These legacy attribute values were deprecated in Gradle 5.6, with the intention to add deprecation warnings in 6.0 Better late than never, so we're adding the deprecations now.

Trying to use any of these legacy Usage values in build logic will result in a deprecation warning, as the mutable attribute container emits a warning if it encounters a legacy value.
Additionally, we specially handle legacy Usage attributes in published GMM parsing, as published GMM with these attributes must always be handled in a backwards compatible manner.
In all other cases, traces of these legacy attributes have been removed from the core attribute container implementation. Attribute containers should be agnostic about the attributes they hold, and should not treat certain attributes specially compared to others

Reviewing cheatsheet

Before merging the PR, comments starting with

  • ❌ ❓must be fixed
  • 🤔 💅 should be fixed
  • 💭 may be fixed
  • 🎉 celebrate happy things

@jvandort jvandort added this to the 9.3.0 RC1 milestone Oct 7, 2025
@jvandort jvandort self-assigned this Oct 7, 2025
@jvandort jvandort force-pushed the jvandort/dm/deprecate-legacy-usage-attribute-values branch 2 times, most recently from ad5e8b4 to 70c0d41 Compare October 7, 2025 14:40
@jvandort jvandort requested a review from tresat October 7, 2025 14:40
@jvandort jvandort marked this pull request as ready for review October 7, 2025 14:40
@jvandort jvandort requested review from a team as code owners October 7, 2025 14:40
@jvandort

This comment has been minimized.

@bot-gradle

This comment has been minimized.

@jvandort jvandort force-pushed the jvandort/dm/deprecate-legacy-usage-attribute-values branch from 70c0d41 to d219dac Compare October 7, 2025 18:09
@jvandort jvandort requested a review from a team as a code owner October 7, 2025 18:09
@bot-gradle
Copy link
Collaborator

The following builds have failed:

These legacy attribute values were deprecated in Gradle 5.6, with the intention to add deprecation warnings in 6.0
Better late than never, so we're adding the deprecations now.

Trying to use any of these legacy Usage values in build logic will result in a deprecation warning, as the mutable attribute container
emits a warning if it encounters a legacy value.
Additionally, we specially handle legacy Usage attributes in published GMM parsing, as published GMM with these attributes must always be handled
in a backwards compatible manner.
In all other cases, traces of these legacy attributes have been removed from the core attribute container implementation.
Attribute containers should be agnostic about the attributes they hold, and should not treat certain attributes specially compared to others
@jvandort jvandort force-pushed the jvandort/dm/deprecate-legacy-usage-attribute-values branch from d219dac to 2230307 Compare October 7, 2025 18:26
@jvandort jvandort requested a review from a team as a code owner October 7, 2025 18:26
@jvandort jvandort requested a review from eskatos October 7, 2025 18:26
@jvandort
Copy link
Member Author

jvandort commented Oct 7, 2025

@bot-gradle test this

@bot-gradle

This comment has been minimized.

@bot-gradle
Copy link
Collaborator

The following builds have failed:

Copy link
Member

@lkasso lkasso left a comment

Choose a reason for hiding this comment

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

NIT on upgrade guide.

Use link:{javadocPath}/org/gradle/api/tasks/wrapper/Wrapper.DistributionType.html#values()[`Wrapper.DistributionType.values()`] to obtain the available distribution types instead.

[[deprecate_legacy_usage_values]]
==== Deprecated legacy Usage attribute values
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
==== Deprecated legacy Usage attribute values
==== Deprecated legacy `Usage` attribute values

[[deprecate_legacy_usage_values]]
==== Deprecated legacy Usage attribute values

Since Gradle 5.6, the link:{javadocPath}/org/gradle/api/attributes/Usage.html[`Usage`] attribute was split into a separate link:{javadocPath}/org/gradle/api/attributes/LibraryElements.html[`LibraryElements`] attribute.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Since Gradle 5.6, the link:{javadocPath}/org/gradle/api/attributes/Usage.html[`Usage`] attribute was split into a separate link:{javadocPath}/org/gradle/api/attributes/LibraryElements.html[`LibraryElements`] attribute.
Since Gradle 5.6, the link:{javadocPath}/org/gradle/api/attributes/Usage.html[`Usage`] attribute has been split into a separate link:{javadocPath}/org/gradle/api/attributes/LibraryElements.html[`LibraryElements`] attribute.

==== Deprecated legacy Usage attribute values

Since Gradle 5.6, the link:{javadocPath}/org/gradle/api/attributes/Usage.html[`Usage`] attribute was split into a separate link:{javadocPath}/org/gradle/api/attributes/LibraryElements.html[`LibraryElements`] attribute.
In the JVM ecosystem, `Usage` controls whether a variant is intended for compilation or runtime, while `LibraryElements` controls the format of the artifact (for example, JAR or classes directory).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In the JVM ecosystem, `Usage` controls whether a variant is intended for compilation or runtime, while `LibraryElements` controls the format of the artifact (for example, JAR or classes directory).
In the JVM ecosystem, `Usage` indicates whether a variant is intended for compilation or runtime, while `LibraryElements` specifies the format of the artifact (for example, a JAR file or a classes directory).

Since Gradle 5.6, the link:{javadocPath}/org/gradle/api/attributes/Usage.html[`Usage`] attribute was split into a separate link:{javadocPath}/org/gradle/api/attributes/LibraryElements.html[`LibraryElements`] attribute.
In the JVM ecosystem, `Usage` controls whether a variant is intended for compilation or runtime, while `LibraryElements` controls the format of the artifact (for example, JAR or classes directory).

In order to ease the migration, Gradle automatically maps legacy `Usage` values to the corresponding `Usage` and `LibraryElements` values:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In order to ease the migration, Gradle automatically maps legacy `Usage` values to the corresponding `Usage` and `LibraryElements` values:
To ease migration, Gradle has automatically mapped legacy `Usage` values to their corresponding `Usage` and `LibraryElements` pairs:

In the JVM ecosystem, `Usage` controls whether a variant is intended for compilation or runtime, while `LibraryElements` controls the format of the artifact (for example, JAR or classes directory).

In order to ease the migration, Gradle automatically maps legacy `Usage` values to the corresponding `Usage` and `LibraryElements` values:
|===
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
|===
|===

| `java-runtime-resources` | `java-runtime` | `resources`
|===

Starting in Gradle 10, Gradle will no longer perform this automatic mapping when a legacy `Usage` value is added to an `AttributeContainer` in build logic.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Starting in Gradle 10, Gradle will no longer perform this automatic mapping when a legacy `Usage` value is added to an `AttributeContainer` in build logic.
Starting with Gradle 10, this automatic mapping will no longer occur when legacy `Usage` values are added directly to an `AttributeContainer` in build logic.

|===

Starting in Gradle 10, Gradle will no longer perform this automatic mapping when a legacy `Usage` value is added to an `AttributeContainer` in build logic.
In order to maintain backward compatibility with published metadata, Gradle will continue to translate legacy `Usage` values found in published Gradle Module Metadata.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In order to maintain backward compatibility with published metadata, Gradle will continue to translate legacy `Usage` values found in published Gradle Module Metadata.
To maintain backward compatibility, Gradle will continue translating legacy `Usage` values found in published Gradle Module Metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants