Skip to content

Commit da0cd69

Browse files
authored
Revert automated changes made to deprecated settings.gradle (plugins.each) (flutter#140037)
Restore testing deprecated settings.gradle (plugins.each). Updated presumably by accident in flutter#83067 Split from flutter#137115 See also flutter#137115 (comment)
1 parent 62d6999 commit da0cd69

File tree

3 files changed

+54
-27
lines changed

3 files changed

+54
-27
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Deprecated settings.gradle
22

3-
This project is meant to test that apps using the current `android/settings.gradle`
4-
can still be built. This project can be removed once apps have been migrated to
5-
this new file.
3+
This project is meant to test that apps using the deprecated
4+
`android/settings.gradle` (_PluginEach_ used until Flutter v1.22.0) can still be built.
5+
This project can be removed once apps have been migrated to this new file.
66

77
Issue: https://github.com/flutter/flutter/issues/54566

dev/integration_tests/gradle_deprecated_settings/android/settings.gradle

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,23 @@
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 settings.gradle files in the Flutter repo,
7-
// See dev/tools/bin/generate_gradle_lockfiles.dart.
5+
// This is the `settings.gradle` file that apps were created with until Flutter
6+
// v1.22.0. This file has changed, so it must be migrated in existing projects.
87

9-
pluginManagement {
10-
def flutterSdkPath = {
11-
def properties = new Properties()
12-
file("local.properties").withInputStream { properties.load(it) }
13-
def flutterSdkPath = properties.getProperty("flutter.sdk")
14-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
15-
return flutterSdkPath
16-
}
17-
settings.ext.flutterSdkPath = flutterSdkPath()
8+
include ':app'
189

19-
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
10+
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
11+
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
12+
def properties = new Properties()
2013

21-
plugins {
22-
id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
23-
}
14+
def plugins = new Properties()
15+
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
16+
if (pluginsFile.exists()) {
17+
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
2418
}
2519

26-
include ":app"
27-
28-
apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"
20+
plugins.each { name, path ->
21+
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
22+
include ":$name"
23+
project(":$name").projectDir = pluginDirectory
24+
}

packages/flutter_tools/test/integration.shard/deprecated_gradle_settings_test.dart

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

5+
import 'package:file/src/interface/file.dart';
56
import 'package:file_testing/file_testing.dart';
67
import 'package:flutter_tools/src/base/io.dart';
78

@@ -16,6 +17,40 @@ void main() {
1617
final String workingDirectory = fileSystem.path.join(getFlutterRoot(), 'dev', 'integration_tests', 'gradle_deprecated_settings');
1718
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
1819

20+
final File settingsDotGradleFile = fileSystem.file(
21+
fileSystem.path.join(workingDirectory, 'android', 'settings.gradle'));
22+
const String expectedSettingsDotGradle = r"""
23+
// Copyright 2014 The Flutter Authors. All rights reserved.
24+
// Use of this source code is governed by a BSD-style license that can be
25+
// found in the LICENSE file.
26+
27+
// This is the `settings.gradle` file that apps were created with until Flutter
28+
// v1.22.0. This file has changed, so it must be migrated in existing projects.
29+
30+
include ':app'
31+
32+
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
33+
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
34+
def properties = new Properties()
35+
36+
def plugins = new Properties()
37+
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
38+
if (pluginsFile.exists()) {
39+
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
40+
}
41+
42+
plugins.each { name, path ->
43+
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
44+
include ":$name"
45+
project(":$name").projectDir = pluginDirectory
46+
}
47+
""";
48+
49+
expect(
50+
settingsDotGradleFile.readAsStringSync().trim().replaceAll('\r', ''),
51+
equals(expectedSettingsDotGradle.trim()),
52+
);
53+
1954
final ProcessResult result = await processManager.run(<String>[
2055
flutterBin,
2156
'build',
@@ -25,11 +60,7 @@ void main() {
2560
'--verbose',
2661
], workingDirectory: workingDirectory);
2762

28-
printOnFailure('Output of flutter build apk:');
29-
printOnFailure(result.stdout.toString());
30-
printOnFailure(result.stderr.toString());
31-
32-
expect(result.exitCode, 0);
63+
expect(result, const ProcessResultMatcher());
3364

3465
final String apkPath = fileSystem.path.join(
3566
workingDirectory, 'build', 'app', 'outputs', 'flutter-apk', 'app-debug.apk');

0 commit comments

Comments
 (0)