Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FGP conversion] Port FlutterExtension from Groovy to Kotlin #165143

Merged
merged 7 commits into from
Mar 13, 2025

Conversation

gmackall
Copy link
Member

@gmackall gmackall commented Mar 13, 2025

Ports FlutterExtension from groovy to kotlin.

Fixes #162105

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. labels Mar 13, 2025

// The default getter name that Kotlin creates conflicts with the above methods.
@get:JvmName("getVersionCodeProperty")
val versionCode: Int
Copy link
Member Author

Choose a reason for hiding this comment

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

In groovy the presence of a getVersionCode/getVersionName allows the syntactic sugar flutter.versionCode/versionName. You can read about this here
https://www.groovy-lang.org/objectorientation.html#properties

By convention, Groovy will recognize properties even if there is no backing field provided there are getters or setters that follow the Java Beans specification. For example:

class PseudoProperties {
    // a pseudo property "name"
    void setName(String name) {}
    String getName() {}

    // a pseudo read-only property "age"
    int getAge() { 42 }

    // a pseudo write-only property "groovy"
    void setGroovy(boolean groovy) {  }
}
def p = new PseudoProperties()
p.name = 'Foo'                      (1)
assert p.age == 42                  (2)
p.groovy = true                     (3)

(1) writing p.name is allowed because there is a pseudo-property name
(2) reading p.age is allowed because there is a pseudo-readonly property age
(3) writing p.groovy is allowed because there is a pseudo-write-only property groovy

But then having a versionCode property, a getter for that property, and also a getVersionCode property causes an error because Kotlin implicitly names the getter getVersionCode. So I'm renaming the generated getter name here, because it doesn't actually matter what it is (all that matters is that we have an equivalent for the syntactic sugar that Groovy was generating, i.e. referencing it as flutter.versionCode).

@gmackall gmackall marked this pull request as ready for review March 13, 2025 20:19
@gmackall gmackall requested a review from a team March 13, 2025 20:19
@gmackall gmackall added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Mar 13, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Mar 13, 2025
Merged via the queue into flutter:master with commit 6806015 Mar 13, 2025
135 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 13, 2025
Copy link
Contributor

@reidbaker reidbaker left a comment

Choose a reason for hiding this comment

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

Post merge approval.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FGP Kotlin conversion] Convert FlutterExtension
3 participants