Skip to content

Commit b8e56e3

Browse files
authored
Fix use of deprecated buildDir in Android templates/tests/examples (#157560)
Replace deprecated `Project.buildDir` [getter](https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html#getBuildDir()) and [setter](https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html#setBuildDir(java.io.File)) uses.
1 parent 2e23f7b commit b8e56e3

File tree

23 files changed

+63
-55
lines changed

23 files changed

+63
-55
lines changed

dev/benchmarks/macrobenchmarks/android/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ allprojects {
1313
}
1414
}
1515

16-
rootProject.buildDir = '../build'
16+
Directory newBuildDir = rootProject.layout.buildDirectory.dir("../../build").get()
17+
rootProject.layout.buildDirectory.value(newBuildDir)
1718

1819
subprojects {
19-
project.buildDir = "${rootProject.buildDir}/${project.name}"
20+
def newSubprojectBuildDir = newBuildDir.dir(project.name)
21+
project.layout.buildDirectory.value(newSubprojectBuildDir)
2022
}
2123
subprojects {
2224
project.evaluationDependsOn(':app')
@@ -30,5 +32,5 @@ subprojects {
3032
}
3133

3234
tasks.register("clean", Delete) {
33-
delete rootProject.buildDir
35+
delete rootProject.layout.buildDirectory
3436
}

dev/benchmarks/microbenchmarks/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ allprojects {
99
}
1010
}
1111

12-
rootProject.buildDir = '../build'
12+
rootProject.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir("../../build").get())
1313

1414
subprojects {
15-
project.buildDir = "${rootProject.buildDir}/${project.name}"
15+
project.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir(project.name).get())
1616
}
1717
subprojects {
1818
project.evaluationDependsOn(':app')
@@ -25,5 +25,5 @@ subprojects {
2525
}
2626

2727
tasks.register("clean", Delete) {
28-
delete rootProject.buildDir
28+
delete rootProject.layout.buildDirectory
2929
}

dev/benchmarks/multiple_flutters/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ allprojects {
2626
}
2727

2828
tasks.register("clean", Delete) {
29-
delete rootProject.buildDir
29+
delete rootProject.layout.buildDirectory
3030
}

dev/integration_tests/deferred_components_test/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ project.getTasks().withType(JavaCompile){
3434
options.compilerArgs << "-Xlint:all" << "-Werror"
3535
}
3636

37-
rootProject.buildDir = '../build'
37+
rootProject.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir("../../build").get())
3838

3939
subprojects {
40-
project.buildDir = "${rootProject.buildDir}/${project.name}"
40+
project.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir(project.name).get())
4141
project.evaluationDependsOn(':app')
4242

4343
dependencyLocking {
@@ -50,5 +50,5 @@ subprojects {
5050
}
5151

5252
tasks.register("clean", Delete) {
53-
delete rootProject.buildDir
53+
delete rootProject.layout.buildDirectory
5454
}

dev/integration_tests/deferred_components_test/android/component1/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ android {
2828

2929
sourceSets {
3030
applicationVariants.all { variant ->
31-
main.assets.srcDirs += "${project.buildDir}/intermediates/flutter/${variant.name}/deferred_assets"
32-
main.jniLibs.srcDirs += "${project.buildDir}/intermediates/flutter/${variant.name}/deferred_libs"
31+
main.assets.srcDirs += "${project.layout.buildDirectory.get()}/intermediates/flutter/${variant.name}/deferred_assets"
32+
main.jniLibs.srcDirs += "${project.layout.buildDirectory.get()}/intermediates/flutter/${variant.name}/deferred_libs"
3333
}
3434
}
3535

dev/integration_tests/gradle_deprecated_settings/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ allprojects {
2929
}
3030
}
3131

32-
rootProject.buildDir = '../build'
32+
rootProject.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir("../../build").get())
3333

3434
subprojects {
35-
project.buildDir = "${rootProject.buildDir}/${project.name}"
35+
project.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir(project.name).get())
3636
}
3737
subprojects {
3838
project.evaluationDependsOn(':app')
@@ -46,5 +46,5 @@ subprojects {
4646
}
4747

4848
tasks.register("clean", Delete) {
49-
delete rootProject.buildDir
49+
delete rootProject.layout.buildDirectory
5050
}

dev/integration_tests/module_host_with_custom_build_v2_embedding/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ allprojects {
2020
}
2121

2222
tasks.register("clean", Delete) {
23-
delete rootProject.buildDir
23+
delete rootProject.layout.buildDirectory
2424
}

dev/integration_tests/native_driver_test/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ allprojects {
99
}
1010
}
1111

12-
rootProject.buildDir = "../build"
12+
rootProject.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir("../../build").get())
1313
subprojects {
14-
project.buildDir = "${rootProject.buildDir}/${project.name}"
14+
project.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir(project.name).get())
1515
}
1616
subprojects {
1717
project.evaluationDependsOn(":app")
1818
}
1919

2020
tasks.register("clean", Delete) {
21-
delete rootProject.buildDir
21+
delete rootProject.layout.buildDirectory
2222
}

dev/tools/bin/generate_gradle_lockfiles.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ allprojects {
237237
}
238238
}
239239
240-
rootProject.buildDir = '../build'
240+
rootProject.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir("../../build").get())
241241
242242
subprojects {
243-
project.buildDir = "${rootProject.buildDir}/${project.name}"
243+
project.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir(project.name).get())
244244
}
245245
subprojects {
246246
project.evaluationDependsOn(':app')
@@ -254,7 +254,7 @@ subprojects {
254254
}
255255
256256
tasks.register("clean", Delete) {
257-
delete rootProject.buildDir
257+
delete rootProject.layout.buildDirectory
258258
}
259259
''';
260260

dev/tracing_tests/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ allprojects {
99
}
1010
}
1111

12-
rootProject.buildDir = '../build'
12+
rootProject.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir("../../build").get())
1313
subprojects {
14-
project.buildDir = "${rootProject.buildDir}/${project.name}"
14+
project.layout.buildDirectory.value(rootProject.layout.buildDirectory.dir(project.name).get())
1515
}
1616
subprojects {
1717
project.evaluationDependsOn(':app')
1818
}
1919

2020
tasks.register("clean", Delete) {
21-
delete rootProject.buildDir
21+
delete rootProject.layout.buildDirectory
2222
}

0 commit comments

Comments
 (0)