Skip to content

Commit f7b24fa

Browse files
authored
Revert "Add a warning/additional handlers for parsingsynthetic-package." (#158078)
Reverts flutter/flutter#157934 to unblock flutter/flutter#158076 and then flutter roll. Reason: b/377107864
1 parent a1651c6 commit f7b24fa

File tree

3 files changed

+5
-209
lines changed

3 files changed

+5
-209
lines changed

packages/flutter_tools/lib/src/commands/generate_localizations.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ class GenerateLocalizationsCommand extends FlutterCommand {
147147
'generated as a synthetic package or at a specified directory in '
148148
'the Flutter project.\n'
149149
'\n'
150-
'DEPRECATED: https://flutter.dev/to/flutter-gen-deprecation.\n'
151-
'\n'
152150
'This flag is set to true by default.\n'
153151
'\n'
154152
'When synthetic-package is set to false, it will generate the '

packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Future<void> generateLocalizationsSyntheticPackage({
1515
required BuildSystem buildSystem,
1616
required BuildTargets buildTargets,
1717
}) async {
18+
1819
final FileSystem fileSystem = environment.fileSystem;
1920
final File l10nYamlFile = fileSystem.file(
20-
fileSystem.path.join(environment.projectDir.path, 'l10n.yaml'),
21-
);
21+
fileSystem.path.join(environment.projectDir.path, 'l10n.yaml'));
2222

2323
// If pubspec.yaml has generate:true and if l10n.yaml exists in the
2424
// root project directory, check to see if a synthetic package should
@@ -30,7 +30,7 @@ Future<void> generateLocalizationsSyntheticPackage({
3030
final YamlNode yamlNode = loadYamlNode(l10nYamlFile.readAsStringSync());
3131
if (yamlNode.value != null && yamlNode is! YamlMap) {
3232
throwToolExit(
33-
'Expected ${l10nYamlFile.path} to contain a map, instead was $yamlNode',
33+
'Expected ${l10nYamlFile.path} to contain a map, instead was $yamlNode'
3434
);
3535
}
3636

@@ -41,7 +41,8 @@ Future<void> generateLocalizationsSyntheticPackage({
4141
final Object? value = yamlMap['synthetic-package'];
4242
if (value is! bool && value != null) {
4343
throwToolExit(
44-
'Expected "synthetic-package" to have a bool value, instead was "$value"',
44+
'Expected "synthetic-package" to have a bool value, '
45+
'instead was "$value"'
4546
);
4647
}
4748

@@ -51,30 +52,8 @@ Future<void> generateLocalizationsSyntheticPackage({
5152
if (isSyntheticL10nPackage == false) {
5253
return;
5354
}
54-
} else if (!environment.useImplicitPubspecResolution) {
55-
// --no-implicit-pubspec-resolution was passed, and synthetic-packages: true was not.
56-
return;
5755
}
5856

59-
if (!environment.useImplicitPubspecResolution) {
60-
throwToolExit(
61-
'Cannot generate a synthetic package when --no-implicit-pubspec-resolution is passed.\n'
62-
'\n'
63-
'Synthetic package output (package:flutter_gen) is deprecated: '
64-
'https://flutter.dev/to/flutter-gen-deprecation. If you are seeing this '
65-
'message either you have provided --no-implicit-pubspec-resolution, or '
66-
'it is the default value (see flutter --verbose --help).',
67-
);
68-
}
69-
70-
// Log a warning: synthetic-package: true (or implicit true) is deprecated.
71-
environment.logger.printWarning(
72-
'Synthetic package output (package:flutter_gen) is deprecated: '
73-
'https://flutter.dev/to/flutter-gen-deprecation. In a future release, '
74-
'synthetic-package will default to `false` and will later be removed '
75-
'entirely.',
76-
);
77-
7857
final BuildResult result = await buildSystem.build(
7958
buildTargets.generateLocalizationsTarget,
8059
environment,

packages/flutter_tools/test/general.shard/dart/generate_synthetic_packages_test.dart

Lines changed: 0 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -267,185 +267,4 @@ void main() {
267267
throwsToolExit(message: 'to have a bool value, instead was "nonBoolValue"'),
268268
);
269269
});
270-
271-
testWithoutContext('synthetic-package: true (implicit) logs a deprecation warning', () async {
272-
// Project directory setup for gen_l10n logic.
273-
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
274-
275-
// Add generate:true to pubspec.yaml.
276-
final File pubspecFile = fileSystem.file('pubspec.yaml')..createSync();
277-
final String content = pubspecFile.readAsStringSync().replaceFirst(
278-
'\nflutter:\n',
279-
'\nflutter:\n generate: true\n',
280-
);
281-
pubspecFile.writeAsStringSync(content);
282-
283-
// Create a blank l10n.yaml file.
284-
fileSystem.file('l10n.yaml').writeAsStringSync('');
285-
286-
final BufferLogger mockBufferLogger = BufferLogger.test();
287-
final Environment environment = Environment.test(
288-
fileSystem.currentDirectory,
289-
fileSystem: fileSystem,
290-
logger: mockBufferLogger,
291-
artifacts: Artifacts.test(),
292-
processManager: FakeProcessManager.any(),
293-
);
294-
final TestBuildSystem buildSystem = TestBuildSystem.all(BuildResult(success: true));
295-
296-
await generateLocalizationsSyntheticPackage(
297-
environment: environment,
298-
buildSystem: buildSystem,
299-
buildTargets: const BuildTargetsImpl(),
300-
);
301-
302-
expect(
303-
mockBufferLogger.warningText,
304-
contains('https://flutter.dev/to/flutter-gen-deprecation'),
305-
);
306-
});
307-
308-
testWithoutContext('synthetic-package: true (explicit) logs a deprecation warning', () async {
309-
// Project directory setup for gen_l10n logic.
310-
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
311-
312-
// Add generate:true to pubspec.yaml.
313-
final File pubspecFile = fileSystem.file('pubspec.yaml')..createSync();
314-
final String content = pubspecFile.readAsStringSync().replaceFirst(
315-
'\nflutter:\n',
316-
'\nflutter:\n generate: true\n',
317-
);
318-
pubspecFile.writeAsStringSync(content);
319-
fileSystem.file('l10n.yaml').writeAsStringSync('synthetic-package: true');
320-
321-
final BufferLogger mockBufferLogger = BufferLogger.test();
322-
final Environment environment = Environment.test(
323-
fileSystem.currentDirectory,
324-
fileSystem: fileSystem,
325-
logger: mockBufferLogger,
326-
artifacts: Artifacts.test(),
327-
processManager: FakeProcessManager.any(),
328-
);
329-
final TestBuildSystem buildSystem = TestBuildSystem.all(BuildResult(success: true));
330-
331-
await generateLocalizationsSyntheticPackage(
332-
environment: environment,
333-
buildSystem: buildSystem,
334-
buildTargets: const BuildTargetsImpl(),
335-
);
336-
337-
expect(
338-
mockBufferLogger.warningText,
339-
contains('https://flutter.dev/to/flutter-gen-deprecation'),
340-
);
341-
});
342-
343-
testWithoutContext('synthetic-package: false has no deprecation warning', () async {
344-
// Project directory setup for gen_l10n logic
345-
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
346-
347-
// Add generate:true to pubspec.yaml.
348-
final File pubspecFile = fileSystem.file('pubspec.yaml')..createSync();
349-
final String content = pubspecFile.readAsStringSync().replaceFirst(
350-
'\nflutter:\n',
351-
'\nflutter:\n generate: true\n',
352-
);
353-
pubspecFile.writeAsStringSync(content);
354-
fileSystem.file('l10n.yaml').writeAsStringSync('synthetic-package: false');
355-
356-
final BufferLogger mockBufferLogger = BufferLogger.test();
357-
final Environment environment = Environment.test(
358-
fileSystem.currentDirectory,
359-
fileSystem: fileSystem,
360-
logger: mockBufferLogger,
361-
artifacts: Artifacts.test(),
362-
processManager: FakeProcessManager.any(),
363-
);
364-
final TestBuildSystem buildSystem = TestBuildSystem.all(BuildResult(success: true));
365-
366-
await generateLocalizationsSyntheticPackage(
367-
environment: environment,
368-
buildSystem: buildSystem,
369-
buildTargets: const BuildTargetsImpl(),
370-
);
371-
372-
expect(
373-
mockBufferLogger.warningText,
374-
isNot(contains('https://flutter.dev/to/flutter-gen-deprecation')),
375-
);
376-
});
377-
378-
testWithoutContext('synthetic-package: true with --no-implicit-pubspec-resolution is an error', () async {
379-
// Project directory setup for gen_l10n logic
380-
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
381-
382-
// Add generate:true to pubspec.yaml.
383-
final File pubspecFile = fileSystem.file('pubspec.yaml')..createSync();
384-
final String content = pubspecFile.readAsStringSync().replaceFirst(
385-
'\nflutter:\n',
386-
'\nflutter:\n generate: true\n',
387-
);
388-
pubspecFile.writeAsStringSync(content);
389-
390-
// Create an l10n.yaml file
391-
fileSystem.file('l10n.yaml').writeAsStringSync('synthetic-package: true');
392-
393-
final BufferLogger mockBufferLogger = BufferLogger.test();
394-
final Environment environment = Environment.test(
395-
fileSystem.currentDirectory,
396-
fileSystem: fileSystem,
397-
logger: mockBufferLogger,
398-
artifacts: Artifacts.test(),
399-
processManager: FakeProcessManager.any(),
400-
useImplicitPubspecResolution: false,
401-
);
402-
// Will throw if build is called.
403-
final TestBuildSystem buildSystem = TestBuildSystem.all(null);
404-
405-
await expectLater(
406-
() => generateLocalizationsSyntheticPackage(
407-
environment: environment,
408-
buildSystem: buildSystem,
409-
buildTargets: const NoOpBuildTargets(),
410-
),
411-
throwsToolExit(message: 'Cannot generate a synthetic package when --no-implicit-pubspec-resolution is passed'),
412-
);
413-
});
414-
415-
testWithoutContext('synthetic-package defaults to false if --no-implicit-pubspec-resolution is passed', () async {
416-
// Project directory setup for gen_l10n logic
417-
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
418-
419-
// Add generate:true to pubspec.yaml.
420-
final File pubspecFile = fileSystem.file('pubspec.yaml')..createSync();
421-
final String content = pubspecFile.readAsStringSync().replaceFirst(
422-
'\nflutter:\n',
423-
'\nflutter:\n generate: true\n',
424-
);
425-
pubspecFile.writeAsStringSync(content);
426-
427-
// Create an l10n.yaml file
428-
fileSystem.file('l10n.yaml').writeAsStringSync('');
429-
430-
final BufferLogger mockBufferLogger = BufferLogger.test();
431-
final Environment environment = Environment.test(
432-
fileSystem.currentDirectory,
433-
fileSystem: fileSystem,
434-
logger: mockBufferLogger,
435-
artifacts: Artifacts.test(),
436-
processManager: FakeProcessManager.any(),
437-
useImplicitPubspecResolution: false,
438-
);
439-
// Will throw if build is called.
440-
final TestBuildSystem buildSystem = TestBuildSystem.all(null);
441-
442-
await expectLater(
443-
() => generateLocalizationsSyntheticPackage(
444-
environment: environment,
445-
buildSystem: buildSystem,
446-
buildTargets: const NoOpBuildTargets(),
447-
),
448-
returnsNormally,
449-
);
450-
});
451270
}

0 commit comments

Comments
 (0)