integration_test: migrate to build.gradle.kts (#154125)

Attempt to reland #142008 half a year later.

Benefit: this will be the first plugin in Flutter repo that uses Gradle KTS for Android buildscripts. Once it works fine, we can follow up with migration of more plugins later.

[The previous error message](https://github.com/flutter/flutter/pull/142008#issuecomment-1939558432) was:

```
e: /b/s/w/ir/cache/gradle/caches/jars-8/42139b5be0c79e133a7b5c5c5d5bf731/gradle-7.3.1.jar!/com/android/build/gradle/LibraryExtension.class: Class 'com/android/build/gradle/LibraryExtension' was compiled with an incompatible version of Kotlin. The binary version of its bytecode is unknown, expected version is 1.0.3
e: /b/s/w/ir/cache/gradle/caches/jars-8/043c0d54e2c1bb39208ec4477607cdf5/gradle-api-7.3.1.jar!/com/android/build/api/dsl/LibraryVariantDimension.class: Class 'com/android/build/api/dsl/LibraryVariantDimension' was compiled with an incompatible version of Kotlin. The binary version of its bytecode is unknown, expected version is 1.0.3

FAILURE: Build failed with an exception.

* Where:
Build file '/b/s/w/ir/x/w/flutter/packages/integration_test/android/build.gradle.kts' line: 36

* What went wrong:
com.android.build.gradle.LibraryExtension.setNamespace(Ljava/lang/String;)V
```

The `integration_test` plugin now puts `com.android.tools.build:gradle:8.1.0` on its classpath since https://github.com/flutter/flutter/issues/153795.

This makes me take an optimistic bet that it won't kill the autoroller now 🤞
This commit is contained in:
Bartek Pacia 2024-10-02 17:19:47 +02:00 committed by GitHub
parent 4342887826
commit e819a38292
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 62 additions and 61 deletions

View File

@ -1,60 +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.
group 'dev.flutter.plugins.integration_test'
version '1.0-SNAPSHOT'
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
}
}
rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}
// project.getTasks().withType(JavaCompile){
// options.compilerArgs << "-Xlint:all" << "-Werror"
// }
apply plugin: 'com.android.library'
android {
namespace 'dev.flutter.integration_test'
compileSdk 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'lib-proguard-rules.txt'
}
dependencies {
// TODO(egarciad): These dependencies should not be added to release builds.
// https://github.com/flutter/flutter/issues/56591
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-inline:5.1.0'
api 'androidx.test:runner:1.2+'
api 'androidx.test:rules:1.2+'
api 'androidx.test.espresso:espresso-core:3.2+'
implementation 'com.google.guava:guava:28.1-android'
}
}

View File

@ -0,0 +1,61 @@
// 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.
group = "dev.flutter.plugins.integration_test"
version = "1.0-SNAPSHOT"
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.1.0")
}
}
plugins {
id("com.android.library")
}
rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}
// project.getTasks().withType(JavaCompile){
// options.compilerArgs << "-Xlint:all" << "-Werror"
// }
android {
namespace = "dev.flutter.integration_test"
compileSdk = 34
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
defaultConfig {
minSdk = 21
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("lib-proguard-rules.txt")
}
dependencies {
// TODO(egarciad): These dependencies should not be added to release builds.
// https://github.com/flutter/flutter/issues/56591
testImplementation("junit:junit:4.13.2")
testImplementation("org.mockito:mockito-inline:5.1.0")
api("androidx.test:runner:1.2+")
api("androidx.test:rules:1.2+")
api("androidx.test.espresso:espresso-core:3.2+")
implementation("com.google.guava:guava:28.1-android")
}
}

View File

@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
rootProject.name = 'integrationTest'
rootProject.name = "integrationTest"