integration_test example Android app: migrate to Gradle KTS (#157193)

After this PR is merged, all of `integration_test` Android gradle
buildscripts will be in Kotlin.

Follow-up of https://github.com/flutter/flutter/pull/156291

Part of ongoing effort to use Gradle Kotlin DSL a bit more

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
This commit is contained in:
Bartek Pacia 2025-03-18 16:08:09 +01:00 committed by GitHub
parent 425d1bd258
commit 7efef421ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 115 additions and 134 deletions

View File

@ -1,74 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
plugins {
id "com.android.application"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace 'com.example.integration_test_example'
compileSdk flutter.compileSdkVersion
// Flutter's CI installs the NDK at a non-standard path.
// This non-standard structure is initially created by
// https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh.
String systemNdkPath = System.getenv("ANDROID_NDK_PATH")
if (systemNdkPath != null) {
ndkVersion = flutter.ndkVersion
ndkPath = systemNdkPath
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.integration_test_example"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

View File

@ -0,0 +1,58 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
android {
namespace = "com.example.integration_test_example"
compileSdk = flutter.compileSdkVersion
// Flutter's CI installs the NDK at a non-standard path.
// This non-standard structure is initially created by
// https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh.
val systemNdkPath = System.getenv("ANDROID_NDK_PATH")
if (systemNdkPath != null) {
ndkVersion = flutter.ndkVersion
ndkPath = systemNdkPath
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.integration_test_example"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}
}
flutter {
source = "../.."
}
dependencies {
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test:runner:1.5.2")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}

View File

@ -2,8 +2,7 @@
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
package="com.example.integration_test_example">
<!-- Flutter needs it to communicate with the running application <!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc. to allow setting breakpoints, to provide hot reload, etc.
--> -->

View File

@ -2,8 +2,7 @@
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
package="com.example.integration_test_example">
<!-- ${applicationName} is used by the Flutter tool to select the Application <!-- ${applicationName} is used by the Flutter tool to select the Application
class to use. For most apps, this is the default Android application. class to use. For most apps, this is the default Android application.

View File

@ -2,8 +2,7 @@
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
package="com.example.integration_test_example">
<!-- Flutter needs it to communicate with the running application <!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc. to allow setting breakpoints, to provide hot reload, etc.
--> -->

View File

@ -13,22 +13,22 @@ allprojects {
} }
} }
rootProject.buildDir = '../build' rootProject.buildDir = file("../build")
subprojects { subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}" project.buildDir = file("${rootProject.buildDir}/${project.name}")
} }
subprojects { subprojects {
project.evaluationDependsOn(':app') project.evaluationDependsOn(":app")
dependencyLocking { dependencyLocking {
ignoredDependencies.add('io.flutter:*') ignoredDependencies.add("io.flutter:*")
lockFile = file("${rootProject.projectDir}/project-${project.name}.lockfile") lockFile = file("${rootProject.projectDir}/project-${project.name}.lockfile")
if (!project.hasProperty('local-engine-repo')) { if (!project.hasProperty("local-engine-repo")) {
lockAllConfigurations() lockAllConfigurations()
} }
} }
} }
tasks.register("clean", Delete) { tasks.register<Delete>("clean") {
delete rootProject.buildDir delete(rootProject.buildDir)
} }

View File

@ -129,15 +129,15 @@ org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10=classpath
org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.8.10=classpath org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.8.10=classpath
org.jetbrains.kotlin:kotlin-native-utils:1.8.10=classpath org.jetbrains.kotlin:kotlin-native-utils:1.8.10=classpath
org.jetbrains.kotlin:kotlin-project-model:1.8.10=classpath org.jetbrains.kotlin:kotlin-project-model:1.8.10=classpath
org.jetbrains.kotlin:kotlin-reflect:1.9.20=classpath org.jetbrains.kotlin:kotlin-reflect:2.0.21=classpath
org.jetbrains.kotlin:kotlin-scripting-common:1.8.10=classpath org.jetbrains.kotlin:kotlin-scripting-common:1.8.10=classpath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.8.10=classpath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.8.10=classpath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.8.10=classpath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.8.10=classpath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.8.10=classpath org.jetbrains.kotlin:kotlin-scripting-jvm:1.8.10=classpath
org.jetbrains.kotlin:kotlin-stdlib-common:1.9.20=classpath org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=classpath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.20=classpath org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.20=classpath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20=classpath org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20=classpath
org.jetbrains.kotlin:kotlin-stdlib:1.9.20=classpath org.jetbrains.kotlin:kotlin-stdlib:2.0.21=classpath
org.jetbrains.kotlin:kotlin-tooling-core:1.8.10=classpath org.jetbrains.kotlin:kotlin-tooling-core:1.8.10=classpath
org.jetbrains.kotlin:kotlin-util-io:1.8.10=classpath org.jetbrains.kotlin:kotlin-util-io:1.8.10=classpath
org.jetbrains.kotlin:kotlin-util-klib:1.8.10=classpath org.jetbrains.kotlin:kotlin-util-klib:1.8.10=classpath
@ -146,7 +146,7 @@ org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.4.0=classpath
org.jetbrains.kotlinx:kotlinx-serialization-core:1.4.0=classpath org.jetbrains.kotlinx:kotlinx-serialization-core:1.4.0=classpath
org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.4.0=classpath org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.4.0=classpath
org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0=classpath org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0=classpath
org.jetbrains:annotations:23.0.0=classpath org.jetbrains:annotations:13.0=classpath
org.jvnet.staxex:stax-ex:1.8.1=classpath org.jvnet.staxex:stax-ex:1.8.1=classpath
org.ow2.asm:asm-analysis:9.6=classpath org.ow2.asm:asm-analysis:9.6=classpath
org.ow2.asm:asm-commons:9.6=classpath org.ow2.asm:asm-commons:9.6=classpath

View File

@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip

View File

@ -1,41 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is auto generated.
// To update all the settings.gradle files in the Flutter repo,
// See dev/tools/bin/generate_gradle_lockfiles.dart.
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}
settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
buildscript {
dependencyLocking {
lockFile = file("${rootProject.projectDir}/buildscript-gradle.lockfile")
lockAllConfigurations()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.7.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.10" apply false
}
include ":app"

View File

@ -0,0 +1,41 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is auto generated.
// To update all the settings.gradle files in the Flutter repo,
// See dev/tools/bin/generate_gradle_lockfiles.dart.
pluginManagement {
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
buildscript {
dependencyLocking {
lockFile = file("${rootProject.projectDir}/buildscript-gradle.lockfile")
lockAllConfigurations()
}
}
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.7.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
}
include(":app")