Skip to content

Commit 85888bc

Browse files
authored
Update gradle lockfiles template (#140115)
This PR updates almost* all Gradle buildscripts in the Flutter repo the `example` and `dev` (in particular, in `dev/integration_tests` and in `dev/benchmarks`) directories to apply Flutter's Gradle plugins using the declarative `plugins {}` block. *almost, because: - add-to-app (aka hybrid) apps are not migrated (related flutter/flutter#138756) - apps that purposefully use build files to ensure backward compatibility (e.g. [`gradle_deprecated_settings`](https://github.com/flutter/flutter/tree/3.16.0/dev/integration_tests/gradle_deprecated_settings))
1 parent da375a7 commit 85888bc

File tree

141 files changed

+2334
-1838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2334
-1838
lines changed

dev/a11y_assessments/android/build.gradle

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@
66
// To update all the build.gradle files in the Flutter repo,
77
// See dev/tools/bin/generate_gradle_lockfiles.dart.
88

9-
buildscript {
10-
ext.kotlin_version = '1.7.10'
11-
repositories {
12-
google()
13-
mavenCentral()
14-
}
15-
16-
dependencies {
17-
classpath 'com.android.tools.build:gradle:7.3.0'
18-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
19-
}
20-
21-
configurations.classpath {
22-
resolutionStrategy.activateDependencyLocking()
23-
}
24-
}
25-
269
allprojects {
2710
repositories {
2811
google()

dev/a11y_assessments/android/settings.gradle

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,18 @@ pluginManagement {
1717
settings.ext.flutterSdkPath = flutterSdkPath()
1818

1919
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
20+
21+
repositories {
22+
google()
23+
mavenCentral()
24+
gradlePluginPortal()
25+
}
2026
}
2127

22-
include ":app"
28+
plugins {
29+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
30+
id "com.android.application" version "7.3.0" apply false
31+
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
32+
}
2333

24-
apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"
34+
include ":app"

dev/benchmarks/complex_layout/android/app/build.gradle

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
plugins {
6+
id "com.android.application"
7+
id "dev.flutter.flutter-gradle-plugin"
8+
}
9+
510
def localProperties = new Properties()
611
def localPropertiesFile = rootProject.file('local.properties')
712
if (localPropertiesFile.exists()) {
@@ -10,13 +15,15 @@ if (localPropertiesFile.exists()) {
1015
}
1116
}
1217

13-
def flutterRoot = localProperties.getProperty('flutter.sdk')
14-
if (flutterRoot == null) {
15-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
18+
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
19+
if (flutterVersionCode == null) {
20+
flutterVersionCode = '1'
1621
}
1722

18-
apply plugin: 'com.android.application'
19-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
23+
def flutterVersionName = localProperties.getProperty('flutter.versionName')
24+
if (flutterVersionName == null) {
25+
flutterVersionName = '1.0'
26+
}
2027

2128
android {
2229
namespace "com.yourcompany.complexLayout"

dev/benchmarks/complex_layout/android/build.gradle

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@
66
// To update all the build.gradle files in the Flutter repo,
77
// See dev/tools/bin/generate_gradle_lockfiles.dart.
88

9-
buildscript {
10-
ext.kotlin_version = '1.7.10'
11-
repositories {
12-
google()
13-
mavenCentral()
14-
}
15-
16-
dependencies {
17-
classpath 'com.android.tools.build:gradle:7.3.0'
18-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
19-
}
20-
21-
configurations.classpath {
22-
resolutionStrategy.activateDependencyLocking()
23-
}
24-
}
25-
269
allprojects {
2710
repositories {
2811
google()

dev/benchmarks/complex_layout/android/buildscript-gradle.lockfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This file is expected to be part of source control.
44
androidx.databinding:databinding-common:7.3.0=classpath
55
androidx.databinding:databinding-compiler-common:7.3.0=classpath
6+
com.android.application:com.android.application.gradle.plugin:7.3.0=classpath
67
com.android.databinding:baseLibrary:7.3.0=classpath
78
com.android.tools.analytics-library:crash:30.3.0=classpath
89
com.android.tools.analytics-library:protos:30.3.0=classpath
@@ -109,6 +110,7 @@ org.glassfish.jaxb:jaxb-runtime:2.3.2=classpath
109110
org.glassfish.jaxb:txw2:2.3.2=classpath
110111
org.jdom:jdom2:2.0.6=classpath
111112
org.jetbrains.intellij.deps:trove4j:1.0.20200330=classpath
113+
org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.10=classpath
112114
org.jetbrains.kotlin:kotlin-android-extensions:1.7.10=classpath
113115
org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.7.10=classpath
114116
org.jetbrains.kotlin:kotlin-build-common:1.7.10=classpath

dev/benchmarks/complex_layout/android/settings.gradle

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,24 @@ pluginManagement {
1818

1919
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
2020

21-
plugins {
22-
id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
21+
repositories {
22+
google()
23+
mavenCentral()
24+
gradlePluginPortal()
2325
}
2426
}
2527

26-
include ":app"
28+
buildscript {
29+
dependencyLocking {
30+
lockFile = file("${rootProject.projectDir}/buildscript-gradle.lockfile")
31+
lockAllConfigurations()
32+
}
33+
}
2734

28-
apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"
35+
plugins {
36+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
37+
id "com.android.application" version "7.3.0" apply false
38+
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
39+
}
40+
41+
include ":app"

dev/benchmarks/macrobenchmarks/android/app/build.gradle

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
plugins {
6+
id "com.android.application"
7+
id "dev.flutter.flutter-gradle-plugin"
8+
}
9+
510
def localProperties = new Properties()
611
def localPropertiesFile = rootProject.file('local.properties')
712
if (localPropertiesFile.exists()) {
@@ -10,11 +15,6 @@ if (localPropertiesFile.exists()) {
1015
}
1116
}
1217

13-
def flutterRoot = localProperties.getProperty('flutter.sdk')
14-
if (flutterRoot == null) {
15-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
16-
}
17-
1818
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1919
if (flutterVersionCode == null) {
2020
flutterVersionCode = '1'
@@ -25,9 +25,6 @@ if (flutterVersionName == null) {
2525
flutterVersionName = '1.0'
2626
}
2727

28-
apply plugin: 'com.android.application'
29-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
30-
3128
android {
3229
namespace "com.example.macrobenchmarks"
3330
compileSdk flutter.compileSdkVersion

dev/benchmarks/macrobenchmarks/android/build.gradle

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@
66
// To update all the build.gradle files in the Flutter repo,
77
// See dev/tools/bin/generate_gradle_lockfiles.dart.
88

9-
buildscript {
10-
ext.kotlin_version = '1.7.10'
11-
repositories {
12-
google()
13-
mavenCentral()
14-
}
15-
16-
dependencies {
17-
classpath 'com.android.tools.build:gradle:7.3.0'
18-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
19-
}
20-
21-
configurations.classpath {
22-
resolutionStrategy.activateDependencyLocking()
23-
}
24-
}
25-
269
allprojects {
2710
repositories {
2811
google()

dev/benchmarks/macrobenchmarks/android/buildscript-gradle.lockfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This file is expected to be part of source control.
44
androidx.databinding:databinding-common:7.3.0=classpath
55
androidx.databinding:databinding-compiler-common:7.3.0=classpath
6+
com.android.application:com.android.application.gradle.plugin:7.3.0=classpath
67
com.android.databinding:baseLibrary:7.3.0=classpath
78
com.android.tools.analytics-library:crash:30.3.0=classpath
89
com.android.tools.analytics-library:protos:30.3.0=classpath
@@ -109,6 +110,7 @@ org.glassfish.jaxb:jaxb-runtime:2.3.2=classpath
109110
org.glassfish.jaxb:txw2:2.3.2=classpath
110111
org.jdom:jdom2:2.0.6=classpath
111112
org.jetbrains.intellij.deps:trove4j:1.0.20200330=classpath
113+
org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.10=classpath
112114
org.jetbrains.kotlin:kotlin-android-extensions:1.7.10=classpath
113115
org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.7.10=classpath
114116
org.jetbrains.kotlin:kotlin-build-common:1.7.10=classpath

dev/benchmarks/macrobenchmarks/android/settings.gradle

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,24 @@ pluginManagement {
1818

1919
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
2020

21-
plugins {
22-
id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
21+
repositories {
22+
google()
23+
mavenCentral()
24+
gradlePluginPortal()
2325
}
2426
}
2527

26-
include ":app"
28+
buildscript {
29+
dependencyLocking {
30+
lockFile = file("${rootProject.projectDir}/buildscript-gradle.lockfile")
31+
lockAllConfigurations()
32+
}
33+
}
2734

28-
apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"
35+
plugins {
36+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
37+
id "com.android.application" version "7.3.0" apply false
38+
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
39+
}
40+
41+
include ":app"

dev/benchmarks/microbenchmarks/android/app/build.gradle

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
plugins {
6+
id "com.android.application"
7+
id "dev.flutter.flutter-gradle-plugin"
8+
}
9+
510
def localProperties = new Properties()
611
def localPropertiesFile = rootProject.file('local.properties')
712
if (localPropertiesFile.exists()) {
@@ -10,13 +15,15 @@ if (localPropertiesFile.exists()) {
1015
}
1116
}
1217

13-
def flutterRoot = localProperties.getProperty('flutter.sdk')
14-
if (flutterRoot == null) {
15-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
18+
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
19+
if (flutterVersionCode == null) {
20+
flutterVersionCode = '1'
1621
}
1722

18-
apply plugin: 'com.android.application'
19-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
23+
def flutterVersionName = localProperties.getProperty('flutter.versionName')
24+
if (flutterVersionName == null) {
25+
flutterVersionName = '1.0'
26+
}
2027

2128
android {
2229
namespace "com.yourcompany.microbenchmarks"
@@ -30,8 +37,8 @@ android {
3037
defaultConfig {
3138
minSdkVersion flutter.minSdkVersion
3239
targetSdkVersion flutter.targetSdkVersion
33-
versionCode 1
34-
versionName "0.0.1"
40+
versionCode flutterVersionCode.toInteger()
41+
versionName flutterVersionName
3542
}
3643

3744
buildTypes {

dev/benchmarks/microbenchmarks/android/build.gradle

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// This file is auto generated.
6-
// To update all the build.gradle files in the Flutter repo,
7-
// See dev/tools/bin/generate_gradle_lockfiles.dart.
8-
9-
buildscript {
10-
ext.kotlin_version = '1.7.10'
11-
repositories {
12-
google()
13-
mavenCentral()
14-
}
15-
16-
dependencies {
17-
classpath 'com.android.tools.build:gradle:7.3.0'
18-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
19-
}
20-
21-
configurations.classpath {
22-
resolutionStrategy.activateDependencyLocking()
23-
}
24-
}
25-
265
allprojects {
276
repositories {
287
google()

dev/benchmarks/microbenchmarks/android/settings.gradle

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,29 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// This file is auto generated.
6-
// To update all the build.gradle files in the Flutter repo,
7-
// See dev/tools/bin/generate_gradle_lockfiles.dart.
5+
pluginManagement {
6+
def flutterSdkPath = {
7+
def properties = new Properties()
8+
file("local.properties").withInputStream { properties.load(it) }
9+
def flutterSdkPath = properties.getProperty("flutter.sdk")
10+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11+
return flutterSdkPath
12+
}
13+
settings.ext.flutterSdkPath = flutterSdkPath()
814

9-
include ':app'
15+
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
1016

11-
enableFeaturePreview('ONE_LOCKFILE_PER_PROJECT')
17+
repositories {
18+
google()
19+
mavenCentral()
20+
gradlePluginPortal()
21+
}
22+
}
1223

13-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
14-
def properties = new Properties()
24+
plugins {
25+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
26+
id "com.android.application" version "7.3.0" apply false
27+
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
28+
}
1529

16-
assert localPropertiesFile.exists()
17-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
18-
19-
def flutterSdkPath = properties.getProperty("flutter.sdk")
20-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
21-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
30+
include ":app"

0 commit comments

Comments
 (0)