Skip to content

Commit eaa99f2

Browse files
authored
Stop generate both .kts and non-.kts gradle files for a test project. (#158965)
Closes flutter/flutter#158962.
1 parent 6a14509 commit eaa99f2

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

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

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/io.dart';
88
import 'package:flutter_tools/src/cache.dart';
99

1010
import '../src/common.dart';
11+
import 'test_data/deferred_components_config.dart';
1112
import 'test_data/plugin_each_settings_gradle_project.dart';
1213
import 'test_data/plugin_project.dart';
1314
import 'test_data/project.dart';
@@ -114,12 +115,34 @@ void main() {
114115
test(
115116
'skip plugin with android folder if it does not support the Android platform',
116117
() async {
117-
final Project project = PluginWithPathAndroidProject();
118+
final Project project = PluginWithPathAndroidProjectWithoutDeferred();
118119
final ProcessResult buildApkResult = await testUnsupportedPlugin(
119120
project: project, createAndroidPluginFolder: true);
120121
expect(buildApkResult.stderr.toString(),
121122
isNot(contains('Please fix your settings.gradle')));
122123
expect(buildApkResult, const ProcessResultMatcher());
124+
125+
// Regression check for https://github.com/flutter/flutter/issues/158962.
126+
{
127+
final Directory androidDir = project.dir.childDirectory('android');
128+
expect(
129+
androidDir.childFile('settings.gradle.kts'),
130+
exists,
131+
reason:
132+
'Modern flutter create --platforms android template creates this',
133+
);
134+
expect(
135+
androidDir.childFile('settings.gradle'),
136+
isNot(exists),
137+
reason: ''
138+
'flutter create should have created a settings.gradle.kts file '
139+
'but not a settings.gradle file. Prior to the change in the PR '
140+
'addressing https://github.com/flutter/flutter/issues/158962 '
141+
'both files were created, which means that tooling picked one '
142+
'and not the other, which causes ambiguity for debugging test '
143+
'flakes.',
144+
);
145+
}
123146
});
124147

125148
// TODO(54566): Remove test when issue is resolved.
@@ -186,21 +209,41 @@ dependencies:
186209
path: ../
187210
''';
188211

212+
/// Project that load's a plugin from the specified path.
213+
class PluginWithPathAndroidProjectWithoutDeferred extends PluginProject {
214+
// Intentionally omit; this test case has nothing to do with deferred
215+
// components and a DefererdComponentsConfig will cause duplicates of files
216+
// such as build.gradle{.kts}, settings.gradle{kts} and related to be
217+
// generated, which in turn adds ambiguity to how the tests are built and
218+
// executed.
219+
//
220+
// See https://github.com/flutter/flutter/issues/158962.
221+
@override
222+
DeferredComponentsConfig? get deferredComponents => null;
223+
224+
@override
225+
String get pubspec => pubspecWithPluginPath;
226+
}
227+
189228
/// Project that load's a plugin from the specified path.
190229
class PluginWithPathAndroidProject extends PluginProject {
191230
@override
192231
String get pubspec => pubspecWithPluginPath;
193232
}
194233

195-
// TODO(54566): Remove class when issue is resolved.
234+
// TODO(matanlurey): Remove class when `.flutter-plugins` is no longer emitted.
235+
// See https://github.com/flutter/flutter/issues/48918.
236+
196237
/// [PluginEachSettingsGradleProject] that load's a plugin from the specified
197238
/// path.
198239
class PluginEachWithPathAndroidProject extends PluginEachSettingsGradleProject {
199240
@override
200241
String get pubspec => pubspecWithPluginPath;
201242
}
202243

203-
// TODO(54566): Remove class when issue is resolved.
244+
// TODO(matanlurey): Remove class when `.flutter-plugins` is no longer emitted.
245+
// See https://github.com/flutter/flutter/issues/48918.
246+
204247
/// [PluginCompromisedEachSettingsGradleProject] that load's a plugin from the
205248
/// specified path.
206249
class PluginCompromisedEachWithPathAndroidProject

0 commit comments

Comments
 (0)