mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Reverts "Avoid implicitly setting determineDevDependencies: true
(it's not a safe operation) (#163711)" (#163762)
<!-- start_original_pr_link --> Reverts: flutter/flutter#163711 <!-- end_original_pr_link --> <!-- start_initiating_author --> Initiated by: victorsanni <!-- end_initiating_author --> <!-- start_revert_reason --> Reason for reverting: This is closing the tree. See https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20android_release_builds_exclude_dev_dependencies_test/889/overview <!-- end_revert_reason --> <!-- start_original_pr_author --> Original PR Author: matanlurey <!-- end_original_pr_author --> <!-- start_reviewers --> Reviewed By: {jonahwilliams} <!-- end_reviewers --> <!-- start_revert_body --> This change reverts the following previous change: Closes https://github.com/flutter/flutter/issues/163706. Before this PR, the macOS workflow (or, others, but only macOS had a test) would fail because it calls `refreshPluginsList` manually, and sometimes it would be `determineDevDependencies: null` and sometimes `determineDevDependencies: false`. A value of `determineDevDependencies: null` was interpreted later on as "find dev dependencies", which is not a safe operation. The only real change in this PR is `bool determineDevDependencies = false`, so omitting that parameter means we don't determine dev dependencies. Added some tests, and opted-in an integration test that was failing. <!-- end_revert_body --> Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com>
This commit is contained in:
parent
3decd62f3a
commit
e6730613c9
@ -244,8 +244,9 @@ bool _writeFlutterPluginsList(
|
||||
final String? oldPluginsFileStringContent = _readFileContent(pluginsFile);
|
||||
bool pluginsChanged = true;
|
||||
if (oldPluginsFileStringContent != null) {
|
||||
Object? decodedJson;
|
||||
try {
|
||||
final Object? decodedJson = jsonDecode(oldPluginsFileStringContent);
|
||||
decodedJson = jsonDecode(oldPluginsFileStringContent);
|
||||
if (decodedJson is Map<String, Object?>) {
|
||||
final String jsonOfNewPluginsMap = jsonEncode(pluginsMap);
|
||||
final String jsonOfOldPluginsMap = jsonEncode(decodedJson[_kFlutterPluginsPluginListKey]);
|
||||
@ -1099,17 +1100,12 @@ void _createPlatformPluginSymlinks(
|
||||
/// dependencies declared in `pubspec.yaml`.
|
||||
///
|
||||
/// Assumes `pub get` has been executed since last change to `pubspec.yaml`.
|
||||
///
|
||||
/// Unless explicitly specified, [determineDevDependencies] is disabled by
|
||||
/// default; if set to `true`, plugins that are development-only dependencies
|
||||
/// may be labeled or, depending on the platform, omitted from metadata or
|
||||
/// platform-specific artifacts.
|
||||
Future<void> refreshPluginsList(
|
||||
FlutterProject project, {
|
||||
bool iosPlatform = false,
|
||||
bool macOSPlatform = false,
|
||||
bool forceCocoaPodsOnly = false,
|
||||
bool determineDevDependencies = false,
|
||||
bool? determineDevDependencies,
|
||||
bool? generateLegacyPlugins,
|
||||
}) async {
|
||||
final List<Plugin> plugins = await findPlugins(
|
||||
|
@ -358,12 +358,7 @@ class FlutterProject {
|
||||
if (!directory.existsSync() || isPlugin) {
|
||||
return;
|
||||
}
|
||||
await refreshPluginsList(
|
||||
this,
|
||||
iosPlatform: iosPlatform,
|
||||
macOSPlatform: macOSPlatform,
|
||||
determineDevDependencies: releaseMode ?? false,
|
||||
);
|
||||
await refreshPluginsList(this, iosPlatform: iosPlatform, macOSPlatform: macOSPlatform);
|
||||
if (androidPlatform) {
|
||||
await android.ensureReadyForPlatformSpecificTooling(deprecationBehavior: deprecationBehavior);
|
||||
}
|
||||
|
@ -31,12 +31,6 @@ import '../src/fake_pub_deps.dart';
|
||||
import '../src/fakes.dart';
|
||||
|
||||
void main() {
|
||||
// TODO(matanlurey): Remove after `explicit-package-dependencies` is enabled by default.
|
||||
// See https://github.com/flutter/flutter/issues/160257 for details.
|
||||
FeatureFlags enableExplicitPackageDependencies() {
|
||||
return TestFeatureFlags(isExplicitPackageDependenciesEnabled: true);
|
||||
}
|
||||
|
||||
// TODO(zanderso): remove once FlutterProject is fully refactored.
|
||||
// this is safe since no tests have expectations on the test logger.
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
@ -278,59 +272,6 @@ void main() {
|
||||
await project.regeneratePlatformSpecificTooling();
|
||||
expectExists(project.android.hostAppGradleRoot.childFile('local.properties'));
|
||||
});
|
||||
|
||||
testUsingContext(
|
||||
'omitted release mode does not determine dev dependencies',
|
||||
() async {
|
||||
// Create a plugin.
|
||||
await aPluginProject();
|
||||
// Create a project that depends on that plugin.
|
||||
final FlutterProject project = await projectWithPluginDependency();
|
||||
// Don't bother with Android, we just want the manifest.
|
||||
project.directory.childDirectory('android').deleteSync(recursive: true);
|
||||
|
||||
await project.regeneratePlatformSpecificTooling();
|
||||
expect(
|
||||
project.flutterPluginsDependenciesFile.readAsStringSync(),
|
||||
isNot(contains('"dev_dependency":true')),
|
||||
);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FeatureFlags: enableExplicitPackageDependencies,
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Pub: () => FakePubWithPrimedDeps(devDependencies: <String>{'my_plugin'}),
|
||||
FlutterProjectFactory:
|
||||
() => FlutterProjectFactory(logger: logger, fileSystem: globals.fs),
|
||||
},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'specified release mode determines dev dependencies',
|
||||
() async {
|
||||
// Create a plugin.
|
||||
await aPluginProject();
|
||||
// Create a project that depends on that plugin.
|
||||
final FlutterProject project = await projectWithPluginDependency();
|
||||
// Don't bother with Android, we just want the manifest.
|
||||
project.directory.childDirectory('android').deleteSync(recursive: true);
|
||||
|
||||
await project.regeneratePlatformSpecificTooling(releaseMode: true);
|
||||
expect(
|
||||
project.flutterPluginsDependenciesFile.readAsStringSync(),
|
||||
contains('"dev_dependency":true'),
|
||||
);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FeatureFlags: enableExplicitPackageDependencies,
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Pub: () => FakePubWithPrimedDeps(devDependencies: <String>{'my_plugin'}),
|
||||
FlutterProjectFactory:
|
||||
() => FlutterProjectFactory(logger: logger, fileSystem: globals.fs),
|
||||
},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'injects plugins for macOS',
|
||||
() async {
|
||||
@ -1789,40 +1730,6 @@ Future<FlutterProject> someProject({
|
||||
return FlutterProject.fromDirectory(directory);
|
||||
}
|
||||
|
||||
Future<FlutterProject> projectWithPluginDependency() async {
|
||||
final Directory directory = globals.fs.directory('some_project');
|
||||
directory.childDirectory('.dart_tool').childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "my_plugin",
|
||||
"rootUri": "/plugin_project",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.12"
|
||||
}
|
||||
]
|
||||
}
|
||||
''');
|
||||
directory.childFile('pubspec.yaml')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
name: app_name
|
||||
flutter:
|
||||
|
||||
dependencies:
|
||||
my_plugin:
|
||||
sdk: flutter
|
||||
''');
|
||||
directory.childDirectory('ios').createSync(recursive: true);
|
||||
final Directory androidDirectory = directory.childDirectory('android')
|
||||
..createSync(recursive: true);
|
||||
androidDirectory.childFile('AndroidManifest.xml').writeAsStringSync('<manifest></manifest>');
|
||||
return FlutterProject.fromDirectory(directory);
|
||||
}
|
||||
|
||||
Future<FlutterProject> aPluginProject({bool legacy = true}) async {
|
||||
final Directory directory = globals.fs.directory('plugin_project');
|
||||
directory.childDirectory('ios').createSync(recursive: true);
|
||||
|
@ -5,7 +5,6 @@
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
|
||||
import '../integration.shard/test_utils.dart';
|
||||
import '../src/common.dart';
|
||||
@ -15,20 +14,6 @@ void main() {
|
||||
|
||||
setUpAll(() {
|
||||
processManager.runSync(<String>[flutterBin, 'config', '--enable-macos-desktop']);
|
||||
|
||||
// TODO(matanlurey): Remove after `explicit-package-dependencies` is enabled by default.
|
||||
// See https://github.com/flutter/flutter/issues/160257 for details.
|
||||
if (!explicitPackageDependencies.master.enabledByDefault) {
|
||||
processManager.runSync(<String>[flutterBin, 'config', '--explicit-package-dependencies']);
|
||||
}
|
||||
});
|
||||
|
||||
tearDownAll(() {
|
||||
// TODO(matanlurey): Remove after `explicit-package-dependencies` is enabled by default.
|
||||
// See https://github.com/flutter/flutter/issues/160257 for details.
|
||||
if (!explicitPackageDependencies.master.enabledByDefault) {
|
||||
processManager.runSync(<String>[flutterBin, 'config', '--no-explicit-package-dependencies']);
|
||||
}
|
||||
});
|
||||
|
||||
for (final String buildMode in <String>['Debug', 'Release']) {
|
||||
|
Loading…
Reference in New Issue
Block a user