From eaa99f28b1cebf39be5fe92633d79af0b64fe329 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Thu, 14 Nov 2024 17:38:26 -0800 Subject: [PATCH] Stop generate both `.kts` and non-`.kts` gradle files for a test project. (#158965) Closes https://github.com/flutter/flutter/issues/158962. --- .../android_plugin_skip_unsupported_test.dart | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/packages/flutter_tools/test/integration.shard/android_plugin_skip_unsupported_test.dart b/packages/flutter_tools/test/integration.shard/android_plugin_skip_unsupported_test.dart index 151d065341..297dc6a725 100644 --- a/packages/flutter_tools/test/integration.shard/android_plugin_skip_unsupported_test.dart +++ b/packages/flutter_tools/test/integration.shard/android_plugin_skip_unsupported_test.dart @@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/cache.dart'; import '../src/common.dart'; +import 'test_data/deferred_components_config.dart'; import 'test_data/plugin_each_settings_gradle_project.dart'; import 'test_data/plugin_project.dart'; import 'test_data/project.dart'; @@ -114,12 +115,34 @@ void main() { test( 'skip plugin with android folder if it does not support the Android platform', () async { - final Project project = PluginWithPathAndroidProject(); + final Project project = PluginWithPathAndroidProjectWithoutDeferred(); final ProcessResult buildApkResult = await testUnsupportedPlugin( project: project, createAndroidPluginFolder: true); expect(buildApkResult.stderr.toString(), isNot(contains('Please fix your settings.gradle'))); expect(buildApkResult, const ProcessResultMatcher()); + + // Regression check for https://github.com/flutter/flutter/issues/158962. + { + final Directory androidDir = project.dir.childDirectory('android'); + expect( + androidDir.childFile('settings.gradle.kts'), + exists, + reason: + 'Modern flutter create --platforms android template creates this', + ); + expect( + androidDir.childFile('settings.gradle'), + isNot(exists), + reason: '' + 'flutter create should have created a settings.gradle.kts file ' + 'but not a settings.gradle file. Prior to the change in the PR ' + 'addressing https://github.com/flutter/flutter/issues/158962 ' + 'both files were created, which means that tooling picked one ' + 'and not the other, which causes ambiguity for debugging test ' + 'flakes.', + ); + } }); // TODO(54566): Remove test when issue is resolved. @@ -186,13 +209,31 @@ dependencies: path: ../ '''; +/// Project that load's a plugin from the specified path. +class PluginWithPathAndroidProjectWithoutDeferred extends PluginProject { + // Intentionally omit; this test case has nothing to do with deferred + // components and a DefererdComponentsConfig will cause duplicates of files + // such as build.gradle{.kts}, settings.gradle{kts} and related to be + // generated, which in turn adds ambiguity to how the tests are built and + // executed. + // + // See https://github.com/flutter/flutter/issues/158962. + @override + DeferredComponentsConfig? get deferredComponents => null; + + @override + String get pubspec => pubspecWithPluginPath; +} + /// Project that load's a plugin from the specified path. class PluginWithPathAndroidProject extends PluginProject { @override String get pubspec => pubspecWithPluginPath; } -// TODO(54566): Remove class when issue is resolved. +// TODO(matanlurey): Remove class when `.flutter-plugins` is no longer emitted. +// See https://github.com/flutter/flutter/issues/48918. + /// [PluginEachSettingsGradleProject] that load's a plugin from the specified /// path. class PluginEachWithPathAndroidProject extends PluginEachSettingsGradleProject { @@ -200,7 +241,9 @@ class PluginEachWithPathAndroidProject extends PluginEachSettingsGradleProject { String get pubspec => pubspecWithPluginPath; } -// TODO(54566): Remove class when issue is resolved. +// TODO(matanlurey): Remove class when `.flutter-plugins` is no longer emitted. +// See https://github.com/flutter/flutter/issues/48918. + /// [PluginCompromisedEachSettingsGradleProject] that load's a plugin from the /// specified path. class PluginCompromisedEachWithPathAndroidProject