Skip to content

Remove deprecated Configuration.setVisible(boolean) calls (Gradle 9.8) - #816

Open
breskeby wants to merge 3 commits into
google:masterfrom
breskeby:fix-gradle-9-8-milestone-2-deprecation
Open

breskeby wants to merge 3 commits into
google:masterfrom
breskeby:fix-gradle-9-8-milestone-2-deprecation

Conversation

@breskeby

@breskeby breskeby commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Gradle 9.8.0-milestone-2 deprecates Configuration.setVisible(boolean) (scheduled for removal in Gradle 11). The protobuf-gradle-plugin sets visible = false on three internal configurations, so any build that treats deprecations as errors (org.gradle.warning.mode=fail) fails as soon as the plugin is applied:

The Configuration.setVisible(boolean) method has been deprecated. This is
scheduled to be removed in Gradle 11.
  ...
  at com.google.protobuf.gradle.ProtobufPlugin...

See the Gradle 9.8 upgrade guide: #deprecate-visible-property.

Fix

Guard the visible = false calls behind a Gradle version check on the three internal configurations:

  • protobufToolsLocator_* (ToolsLocator)
  • the per-source-set protobuf configuration (ProtobufPlugin)
  • compileProtoPath (ProtobufPlugin)
if (GradleVersion.current() < GradleVersion.version('9.8')) {
  it.visible = false
}

On Gradle 9.8+ the visible property is deprecated and inert, so it is skipped to stay warning-clean. On older Gradle versions the original visible = false behaviour is preserved, keeping these internal configurations out of certain reports/publications.

Context

Surfaced while testing Gradle 9.8.0-milestone-2 against Elasticsearch, which runs with org.gradle.warning.mode=fail. The deprecation was a hard build blocker for projects such as :x-pack:plugin:otel-data that apply this plugin.

Gradle 9.8.0-milestone-2 deprecates Configuration.setVisible(boolean)
(scheduled for removal in Gradle 11). The plugin set visible = false on
three internal configurations (protobufToolsLocator_*, the per-source-set
protobuf configuration, and compileProtoPath).

The visible property no longer has any meaningful effect on the build, so
the calls can be dropped without changing behaviour on any supported Gradle
version. This unblocks consumers that run with warning-mode=fail (e.g.
Elasticsearch), where the deprecation is a hard build failure.
Per review feedback on the equivalent nmcp change
(GradleUp/nmcp#271), keep the visible=false
behaviour on Gradle versions where it still matters and only skip it on
Gradle 9.8+ where Configuration.setVisible(boolean) is deprecated and inert.
This avoids the deprecation warning on 9.8+ while preserving original
behaviour on older Gradle versions.
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.

1 participant