Skip to content

fix: avoid implicit parent project property lookup deprecated in Gradle 9 - #157

Closed
andredestro wants to merge 1 commit into
mainfrom
fix/RMET-5591/gradle-implicit-property-lookup
Closed

andredestro wants to merge 1 commit into
mainfrom
fix/RMET-5591/gradle-implicit-property-lookup

Conversation

@andredestro

Copy link
Copy Markdown

Description

New plugins now call hasProperty() on rootProject instead of project when reading app overrides (junitVersion, compileSdkVersion, kotlin_version, etc.). On Gradle 9.8, the old form makes every app that sets these in variables.gradle show "Implicit lookup of properties in parent projects has been deprecated. This will fail with an error in Gradle 10." for the plugin. The value is already read from rootProject, so the behavior is the same.

9 lines in build.gradle.mustache, including the Kotlin-only androidxCoreKTXVersion and kotlin_version lines. Same fix as ionic-team/capacitor#8731 and ionic-team/capacitor-plugins#2640.

Tested by generating a Java and a Kotlin plugin with this branch and adding them to a Capacitor 9 app (Gradle 9.8.2, AGP 9.4.1) whose variables.gradle sets values that differ from the template defaults:

Before After
Java plugin warnings 7 0
Kotlin plugin warnings 6 0

The Java plugin builds (assembleDebug) and picks up the app's values: compileSdk=37 (template default 36), minSdk=27 (template default 24).

The Kotlin plugin fails to build, before and after this change, with Failed to apply plugin 'kotlin-android'. Cannot add extension with name 'kotlin'. AGP 9 has built-in Kotlin support and the template still applies kotlin-android. That is a separate issue and not part of this PR. The warnings counted above are the ones raised before evaluation stops, which include the two Kotlin-only lines.

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

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

Platforms Affected

  • Android
  • iOS
  • Web

…le 9

The template's build.gradle read app overrides with
project.hasProperty('x') ? rootProject.ext.x : default. hasProperty() on a
subproject only finds the value by falling back to the root project, which
Gradle 9 deprecates and Gradle 10 will turn into an error.

Call hasProperty() on rootProject instead, which is where the value is read
from anyway.
@jcesarmobile

Copy link
Copy Markdown
Member

I'll cover this in RMET-4847, some of the replacements you did will mess with migrate-capacitor-plugin as some of the lines you updated are going to be removed or renamed and this changes will make the existing regular expressions or strings not match.

@jcesarmobile
jcesarmobile deleted the fix/RMET-5591/gradle-implicit-property-lookup branch November 19, 2026 18:01
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