flutter/dev/integration_tests/pure_android_host_apps
Gray Mackall d1d9954c45
Support host android apps with kts gradle files for add to app (#156502)
Allows applying of `include_flutter.groovy` via the `apply from:` syntax, which allows using a host app that is using the Gradle Kotlin DSL (the default these days when creating an Android app in AS).

Explanation: The `include_flutter.groovy` script is currently not able to be called by Kotlin gradle files, because it is [intended to be invoked with the following lines](https://docs.flutter.dev/add-to-app/android/project-setup#depend-on-the-modules-source-code):
```
setBinding(new Binding([gradle: this]))                                // new
evaluate(new File(                                                     // new
    settingsDir.parentFile,                                            // new
    'flutter_module/.android/include_flutter.groovy'                   // new
))
```

`setBinding` isn't part of the Kotlin gradle DSL, and there isn't (that I can find) an easy Kotlin equivalent. If this binding isn't set, the reference to `gradle` in `include_flutter.groovy` is wrong, which breaks the script.

This PR modifies `include_flutter.groovy` to also support being invoked through the standard way of invoking a script via the Gradle Groovy/Kotlin DSLs, which is `apply from:` (or it's slightly different Kotlin syntax). The start of the script identifies which of the two approaches is being used by checking if the binding is set, and then initializes some variables differently depending on the case.

If we land this, I believe we should update the example Gradle files for both the `kts` and `groovy` cases to prefer the `apply from` syntax as I think this is the syntax most developers would be more familiar with already seeing in their Gradle files.
2024-10-16 22:47:27 +00:00
..
android_custom_host_app Support host android apps with kts gradle files for add to app (#156502) 2024-10-16 22:47:27 +00:00
android_host_app_v2_embedding Support host android apps with kts gradle files for add to app (#156502) 2024-10-16 22:47:27 +00:00
host_app_kotlin_gradle_dsl Support host android apps with kts gradle files for add to app (#156502) 2024-10-16 22:47:27 +00:00
README.md Support host android apps with kts gradle files for add to app (#156502) 2024-10-16 22:47:27 +00:00

This directory contains minimal Android apps used by integration tests for testing add-to-app use cases.