Repository navigation
fix: move plugin variable lookups to rootProject.hasProperty - #51
Merged
Merged
Conversation
Gradle 9 deprecates project.hasProperty() finding a property that is only
declared on the root project, and Gradle 10 will turn it into an error.
Migrated plugins read app overrides with
project.hasProperty('x') ? rootProject.ext.x : default, so apps get a
warning per variable.
Write the lookups as rootProject.hasProperty(). The existing matchers expect
the project form, so updateBuildGradle normalizes to it after reading and
switches to rootProject before writing, which keeps a second run working.
andredestro
requested review from
ItsChaceD,
OS-pedrogustavobilro,
alexgerardojacinto,
jcesarmobile,
markemer and
theproducer
November 19, 2026 17:30
1 of 6 tasks
alexgerardojacinto
approved these changes
Nov 19, 2026
andredestro
deleted the
fix/RMET-5591/gradle-implicit-property-lookup
branch
November 20, 2026 15:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The migration now moves the plugin's variable lookups from
project.hasProperty('x') ? rootProject.ext.xtorootProject.hasProperty('x') ? rootProject.ext.x.On Gradle 9.8,
project.hasProperty()in a plugin only findsxby falling back to the app's root project. Gradle deprecated that ("Implicit lookup of properties in parent projects ... will fail with an error in Gradle 10"), so every app that sets the variable invariables.gradlegets a warning for each migrated plugin. The value is already read fromrootProject, so the behavior is the same. Capacitor, the official plugins and the plugin template make the same change (ionic-team/capacitor#8731, ionic-team/capacitor-plugins#2640, ionic-team/create-capacitor-plugin#157).updateBuildGradleturns these lookups back into theprojectform right after reading the file, and into therootProjectform right before writing it. The existing matchers (version bumps,kotlin_versionandtargetSdkVersionremoval) look forproject.hasProperty, so without the first step a second run on an already migrated file would stop bumping versions. The regex only matches thex ... rootProject.ext.xpattern with the same name on both sides, so otherhasProperty()calls in the plugin are left alone.Change Type
Rationale / Problems Fixed
https://outsystemsrd.atlassian.net/browse/RMET-5591
https://docs.gradle.org/9.8.2/userguide/upgrading_version_9.html#deprecated_implicit_lookup_in_parent_projects
Tests
src/property-lookup.test.ts: legacy torootProject(single and double quotes, string and numeric defaults), idempotent, back toproject, and otherhasProperty()calls untouched.npm test(44 tests),npm run lintandnpm run buildpass.End to end, on a Kotlin plugin generated by create-capacitor-plugin for Capacitor 8:
rootProject, versions bumped,kotlin_version,kotlin-androidandtargetSdkVersionremoved, AGP 9.4.1rootProjectformThe migrated plugin in a Capacitor 9 app (Gradle 9.8.2,
assembleDebug --warning-mode all) builds with no implicit lookup warnings, and an init script confirmed it picks up the app'svariables.gradlevalues.Platforms Affected