Make releaseMode explicit, inform determineDevDependencies entirely on the flag (#163780)

Closes https://github.com/flutter/flutter/issues/163770.

This simplifies understanding "when I called function X, how is it
determining release mode and/or dev-dependencies?"

AFAICT, at HEAD, this is a NOP (will let integration tests run), but
would have avoided cases such as
https://github.com/flutter/flutter/issues/163706.
This commit is contained in:
Matan Lurey
2025-02-20 16:07:48 -08:00
committed by GitHub
parent 0f586af401
commit f6543c3d45
10 changed files with 101 additions and 72 deletions

View File

@@ -410,7 +410,7 @@ void main() {
final FlutterProject project = FlutterProject.fromDirectoryTest(
fileSystem.directory('project'),
);
await injectPlugins(project, iosPlatform: true);
await injectPlugins(project, iosPlatform: true, releaseMode: false);
final String debugContents =
projectUnderTest.ios.xcodeConfigFor('Debug').readAsStringSync();

View File

@@ -1012,7 +1012,7 @@ dependencies:
() async {
androidProject.embeddingVersion = AndroidEmbeddingVersion.v2;
await injectPlugins(flutterProject, androidPlatform: true);
await injectPlugins(flutterProject, androidPlatform: true, releaseMode: false);
final File registrant = flutterProject.directory
.childDirectory(
@@ -1046,7 +1046,7 @@ dependencies:
await expectLater(
() async {
await injectPlugins(flutterProject, androidPlatform: true);
await injectPlugins(flutterProject, androidPlatform: true, releaseMode: false);
},
throwsToolExit(
message:
@@ -1075,7 +1075,7 @@ dependencies:
createDualSupportJavaPlugin4();
await injectPlugins(flutterProject, androidPlatform: true);
await injectPlugins(flutterProject, androidPlatform: true, releaseMode: false);
final File registrant = flutterProject.directory
.childDirectory(
@@ -1106,7 +1106,7 @@ dependencies:
flutterProject.isModule = true;
androidProject.embeddingVersion = AndroidEmbeddingVersion.v2;
await injectPlugins(flutterProject, androidPlatform: true);
await injectPlugins(flutterProject, androidPlatform: true, releaseMode: false);
final File registrant = flutterProject.directory
.childDirectory(
@@ -1138,7 +1138,7 @@ dependencies:
createNewJavaPlugin1();
await injectPlugins(flutterProject, androidPlatform: true);
await injectPlugins(flutterProject, androidPlatform: true, releaseMode: false);
final File registrant = flutterProject.directory
.childDirectory(
@@ -1169,7 +1169,7 @@ dependencies:
createDualSupportJavaPlugin4();
await injectPlugins(flutterProject, androidPlatform: true);
await injectPlugins(flutterProject, androidPlatform: true, releaseMode: false);
final File registrant = flutterProject.directory
.childDirectory(
@@ -1200,7 +1200,7 @@ dependencies:
createDualSupportJavaPlugin4();
await injectPlugins(flutterProject, androidPlatform: true);
await injectPlugins(flutterProject, androidPlatform: true, releaseMode: false);
final File registrant = flutterProject.directory
.childDirectory(
@@ -1228,7 +1228,7 @@ dependencies:
() async {
final File manifest = fs.file('AndroidManifest.xml');
androidProject.appManifestFile = manifest;
await injectPlugins(flutterProject, androidPlatform: true);
await injectPlugins(flutterProject, androidPlatform: true, releaseMode: false);
},
overrides: <Type, Generator>{
FileSystem: () => fs,
@@ -1372,7 +1372,7 @@ flutter:
dartPluginClass: SomePlugin
''');
await injectPlugins(flutterProject, androidPlatform: true);
await injectPlugins(flutterProject, androidPlatform: true, releaseMode: false);
final File registrantFile = androidProject.pluginRegistrantHost
.childDirectory(fs.path.join('src', 'main', 'java', 'io', 'flutter', 'plugins'))
@@ -1406,6 +1406,7 @@ flutter:
FakeDarwinDependencyManagement();
await injectPlugins(
flutterProject,
releaseMode: false,
iosPlatform: true,
darwinDependencyManagement: dependencyManagement,
);
@@ -1440,6 +1441,7 @@ flutter:
FakeDarwinDependencyManagement();
await injectPlugins(
flutterProject,
releaseMode: false,
macOSPlatform: true,
darwinDependencyManagement: dependencyManagement,
);
@@ -1477,6 +1479,7 @@ flutter:
FakeDarwinDependencyManagement();
await injectPlugins(
flutterProject,
releaseMode: false,
macOSPlatform: true,
darwinDependencyManagement: dependencyManagement,
);
@@ -1510,6 +1513,7 @@ flutter:
FakeDarwinDependencyManagement();
await injectPlugins(
flutterProject,
releaseMode: false,
macOSPlatform: true,
darwinDependencyManagement: dependencyManagement,
);
@@ -1533,7 +1537,7 @@ flutter:
() async {
createFakePlugin(fs);
await injectPlugins(flutterProject, linuxPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, linuxPlatform: true);
final File registrantHeader = linuxProject.managedDirectory.childFile(
'generated_plugin_registrant.h',
@@ -1596,7 +1600,7 @@ dependencies:
flutterProject.manifest = manifest;
await injectPlugins(flutterProject, linuxPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, linuxPlatform: true);
final File registrantImpl = linuxProject.managedDirectory.childFile(
'generated_plugin_registrant.cc',
@@ -1669,7 +1673,7 @@ dependencies:
flutterProject.manifest = manifest;
await injectPlugins(flutterProject, linuxPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, linuxPlatform: true);
final File registrantImpl = linuxProject.managedDirectory.childFile(
'generated_plugin_registrant.cc',
@@ -1706,7 +1710,7 @@ flutter:
dartPluginClass: SomePlugin
''');
await injectPlugins(flutterProject, linuxPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, linuxPlatform: true);
final File registrantImpl = linuxProject.managedDirectory.childFile(
'generated_plugin_registrant.cc',
@@ -1738,7 +1742,7 @@ flutter:
dartPluginClass: SomePlugin
''');
await injectPlugins(flutterProject, linuxPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, linuxPlatform: true);
final File registrantImpl = linuxProject.managedDirectory.childFile(
'generated_plugin_registrant.cc',
@@ -1761,7 +1765,7 @@ flutter:
() async {
createFakePlugin(fs);
await injectPlugins(flutterProject, linuxPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, linuxPlatform: true);
final File pluginMakefile = linuxProject.generatedPluginCmakeFile;
@@ -1799,7 +1803,7 @@ flutter:
'/local_plugins/plugin_b',
]);
await injectPlugins(flutterProject, linuxPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, linuxPlatform: true);
final File pluginCmakeFile = linuxProject.generatedPluginCmakeFile;
final File pluginRegistrant = linuxProject.managedDirectory.childFile(
@@ -1825,7 +1829,7 @@ flutter:
() async {
createFakePlugin(fs);
await injectPlugins(flutterProject, windowsPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, windowsPlatform: true);
final File registrantHeader = windowsProject.managedDirectory.childFile(
'generated_plugin_registrant.h',
@@ -1859,7 +1863,7 @@ flutter:
dartPluginClass: SomePlugin
''');
await injectPlugins(flutterProject, windowsPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, windowsPlatform: true);
final File registrantImpl = windowsProject.managedDirectory.childFile(
'generated_plugin_registrant.cc',
@@ -1890,7 +1894,7 @@ flutter:
dartPluginClass: SomePlugin
''');
await injectPlugins(flutterProject, windowsPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, windowsPlatform: true);
final File registrantImpl = windowsProject.managedDirectory.childFile(
'generated_plugin_registrant.cc',
@@ -1918,7 +1922,7 @@ flutter:
'/local_plugins/plugin_b',
]);
await injectPlugins(flutterProject, windowsPlatform: true);
await injectPlugins(flutterProject, releaseMode: false, windowsPlatform: true);
final File pluginCmakeFile = windowsProject.generatedPluginCmakeFile;
final File pluginRegistrant = windowsProject.managedDirectory.childFile(
@@ -1946,7 +1950,12 @@ flutter:
setUpProject(fsWindows);
createFakePlugin(fsWindows);
await injectPlugins(flutterProject, linuxPlatform: true, windowsPlatform: true);
await injectPlugins(
flutterProject,
releaseMode: false,
linuxPlatform: true,
windowsPlatform: true,
);
for (final CmakeBasedProject? project in <CmakeBasedProject?>[
linuxProject,
@@ -1974,6 +1983,7 @@ flutter:
FakeDarwinDependencyManagement();
await injectPlugins(
flutterProject,
releaseMode: false,
iosPlatform: true,
macOSPlatform: true,
darwinDependencyManagement: dependencyManagement,
@@ -1996,7 +2006,11 @@ flutter:
() async {
final FakeDarwinDependencyManagement dependencyManagement =
FakeDarwinDependencyManagement();
await injectPlugins(flutterProject, darwinDependencyManagement: dependencyManagement);
await injectPlugins(
flutterProject,
releaseMode: false,
darwinDependencyManagement: dependencyManagement,
);
expect(dependencyManagement.setupPlatforms, <SupportedPlatform>[]);
},
overrides: <Type, Generator>{

View File

@@ -125,12 +125,12 @@ void main() {
FlutterManifest.empty(logger: logger),
FlutterManifest.empty(logger: logger),
);
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectNotExists(project.directory);
});
_testInMemory('does nothing in plugin or package root project', () async {
final FlutterProject project = await aPluginProject();
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectNotExists(
project.ios.hostAppRoot.childDirectory('Runner').childFile('GeneratedPluginRegistrant.h'),
);
@@ -148,7 +148,7 @@ void main() {
// that a project was a plugin, but shouldn't be as this creates false
// positives.
project.directory.childDirectory('example').createSync();
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(
project.ios.hostAppRoot.childDirectory('Runner').childFile('GeneratedPluginRegistrant.h'),
);
@@ -162,28 +162,28 @@ void main() {
});
_testInMemory('injects plugins for iOS', () async {
final FlutterProject project = await someProject();
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(
project.ios.hostAppRoot.childDirectory('Runner').childFile('GeneratedPluginRegistrant.h'),
);
});
_testInMemory('generates Xcode configuration for iOS', () async {
final FlutterProject project = await someProject();
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(
project.ios.hostAppRoot.childDirectory('Flutter').childFile('Generated.xcconfig'),
);
});
_testInMemory('injects plugins for Android', () async {
final FlutterProject project = await someProject();
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(
androidPluginRegistrant(project.android.hostAppGradleRoot.childDirectory('app')),
);
});
_testInMemory('updates local properties for Android', () async {
final FlutterProject project = await someProject();
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(project.android.hostAppGradleRoot.childFile('local.properties'));
});
_testInMemory('checkForDeprecation fails on invalid android app manifest file', () async {
@@ -257,7 +257,7 @@ void main() {
final FlutterProject project = await aPluginProject();
project.example.directory.deleteSync();
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expect(
testLogger.statusText,
isNot(
@@ -269,7 +269,7 @@ void main() {
});
_testInMemory('updates local properties for Android', () async {
final FlutterProject project = await someProject();
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(project.android.hostAppGradleRoot.childFile('local.properties'));
});
testUsingContext(
@@ -277,7 +277,7 @@ void main() {
() async {
final FlutterProject project = await someProject();
project.macos.managedDirectory.createSync(recursive: true);
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(project.macos.pluginRegistrantImplementation);
},
overrides: <Type, Generator>{
@@ -293,7 +293,7 @@ void main() {
() async {
final FlutterProject project = await someProject();
project.macos.managedDirectory.createSync(recursive: true);
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(project.macos.generatedXcodePropertiesFile);
},
overrides: <Type, Generator>{
@@ -309,7 +309,7 @@ void main() {
() async {
final FlutterProject project = await someProject();
project.linux.cmakeFile.createSync(recursive: true);
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(project.linux.managedDirectory.childFile('generated_plugin_registrant.h'));
expectExists(project.linux.managedDirectory.childFile('generated_plugin_registrant.cc'));
},
@@ -326,7 +326,7 @@ void main() {
() async {
final FlutterProject project = await someProject();
project.windows.cmakeFile.createSync(recursive: true);
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(project.windows.managedDirectory.childFile('generated_plugin_registrant.h'));
expectExists(
project.windows.managedDirectory.childFile('generated_plugin_registrant.cc'),
@@ -342,7 +342,7 @@ void main() {
);
_testInMemory('creates Android library in module', () async {
final FlutterProject project = await aModuleProject();
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
expectExists(project.android.hostAppGradleRoot.childFile('settings.gradle'));
expectExists(project.android.hostAppGradleRoot.childFile('local.properties'));
expectExists(
@@ -351,7 +351,7 @@ void main() {
});
_testInMemory('creates iOS pod in module', () async {
final FlutterProject project = await aModuleProject();
await project.regeneratePlatformSpecificTooling();
await project.regeneratePlatformSpecificTooling(releaseMode: false);
final Directory flutter = project.ios.hostAppRoot.childDirectory('Flutter');
expectExists(flutter.childFile('podhelper.rb'));
expectExists(flutter.childFile('flutter_export_environment.sh'));