Skip to content

Commit d20f8b0

Browse files
authored
Remove all now inert references to "synthetic" packages. (flutter#169943)
Towards flutter#102983.
1 parent 2d9977c commit d20f8b0

File tree

14 files changed

+10
-246
lines changed

14 files changed

+10
-246
lines changed

packages/flutter_tools/lib/src/build_system/targets/localizations.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import '../../base/file_system.dart';
66
import '../../convert.dart';
7-
import '../../features.dart';
87
import '../../localizations/gen_l10n.dart';
98
import '../../localizations/localizations_utils.dart';
109
import '../build_system.dart';
@@ -60,7 +59,6 @@ class GenerateLocalizationsTarget extends Target {
6059
logger: environment.logger,
6160
fileSystem: environment.fileSystem,
6261
defaultArbDir: defaultArbDir,
63-
defaultSyntheticPackage: !featureFlags.isExplicitPackageDependenciesEnabled,
6462
);
6563
await generateLocalizations(
6664
logger: environment.logger,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ class GenerateLocalizationsCommand extends FlutterCommand {
262262
logger: _logger,
263263
fileSystem: _fileSystem,
264264
defaultArbDir: defaultArbDir,
265-
defaultSyntheticPackage: !featureFlags.isExplicitPackageDependenciesEnabled,
266265
);
267266
_logger.printStatus(
268267
'Because l10n.yaml exists, the options defined there will be used '

packages/flutter_tools/lib/src/flutter_manifest.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,6 @@ class FlutterManifest {
421421
}
422422

423423
/// Whether localization Dart files should be generated.
424-
///
425-
/// **NOTE**: This method was previously called `generateSyntheticPackage`,
426-
/// which was incorrect; the presence of `generate: true` in `pubspec.yaml`
427-
/// does _not_ imply a synthetic package (and never did); additional
428-
/// introspection is required to determine whether a synthetic package is
429-
/// required.
430-
///
431-
/// See also:
432-
///
433-
/// * [Deprecate and remove synthethic `package:flutter_gen`](https://github.com/flutter/flutter/issues/102983)
434424
late final bool generateLocalizations = _flutterDescriptor['generate'] == true;
435425

436426
String? get defaultFlavor => _flutterDescriptor['default-flavor'] as String?;

packages/flutter_tools/lib/src/localizations/gen_l10n.dart

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ Future<LocalizationsGenerator> generateLocalizations({
6666
headerString: options.header,
6767
headerFile: options.headerFile,
6868
useDeferredLoading: options.useDeferredLoading,
69-
useSyntheticPackage: options.syntheticPackage,
7069
areResourceAttributesRequired: options.requiredResourceAttributes,
7170
untranslatedMessagesFile: options.untranslatedMessagesFile,
7271
usesNullableGetter: options.nullableGetter,
@@ -105,18 +104,6 @@ stderr:\n${result.stderr}''', result.exitCode);
105104
return generator;
106105
}
107106

108-
/// The path for the synthetic package.
109-
String _defaultSyntheticPackagePath(FileSystem fileSystem) =>
110-
fileSystem.path.join('.dart_tool', 'flutter_gen');
111-
112-
/// The default path used when the `_useSyntheticPackage` setting is set to true
113-
/// in [LocalizationsGenerator].
114-
///
115-
/// See [LocalizationsGenerator.new] for where and how it is used by the
116-
/// localizations tool.
117-
String _syntheticL10nPackagePath(FileSystem fileSystem) =>
118-
fileSystem.path.join(_defaultSyntheticPackagePath(fileSystem), 'gen_l10n');
119-
120107
// Generate method parameters and also infer the correct types from the usage of the placeholders
121108
// For example, if placeholders are used for plurals and no type was specified, then the type will
122109
// automatically set to 'num'. Similarly, if such placeholders are used for selects, then the type
@@ -545,7 +532,6 @@ class LocalizationsGenerator {
545532
String? headerFile,
546533
bool useDeferredLoading = false,
547534
String? inputsAndOutputsListPath,
548-
bool useSyntheticPackage = false,
549535
String? projectPathString,
550536
bool areResourceAttributesRequired = false,
551537
String? untranslatedMessagesFile,
@@ -562,15 +548,13 @@ class LocalizationsGenerator {
562548
inputPathString,
563549
projectDirectory,
564550
);
565-
final Directory outputDirectory = outputDirectoryFromPath(
551+
final Directory outputDirectory = _outputDirectoryFromPath(
566552
fileSystem,
567553
outputPathString ?? inputPathString,
568-
useSyntheticPackage,
569554
projectDirectory,
570555
);
571556
return LocalizationsGenerator._(
572557
fileSystem,
573-
useSyntheticPackage: useSyntheticPackage,
574558
usesNullableGetter: usesNullableGetter,
575559
className: classNameFromString(classNameString),
576560
projectDirectory: projectDirectory,
@@ -612,7 +596,6 @@ class LocalizationsGenerator {
612596
this.header = '',
613597
this.useDeferredLoading = false,
614598
required this.inputsAndOutputsListFile,
615-
this.useSyntheticPackage = true,
616599
this.projectDirectory,
617600
this.areResourceAttributesRequired = false,
618601
this.untranslatedMessagesFile,
@@ -636,9 +619,6 @@ class LocalizationsGenerator {
636619
);
637620
late final LocaleInfo _templateArbLocale = _templateBundle.locale;
638621

639-
@visibleForTesting
640-
final bool useSyntheticPackage;
641-
642622
// Used to decide if the generated code is nullable or not
643623
// (whether AppLocalizations? or AppLocalizations is returned from
644624
// `static {name}Localizations{?} of (BuildContext context))`
@@ -835,28 +815,16 @@ class LocalizationsGenerator {
835815
}
836816

837817
/// Sets the reference [Directory] for [outputDirectory].
838-
@visibleForTesting
839-
static Directory outputDirectoryFromPath(
818+
static Directory _outputDirectoryFromPath(
840819
FileSystem fileSystem,
841820
String outputPathString,
842-
bool useSyntheticPackage,
843821
Directory? projectDirectory,
844822
) {
845-
Directory outputDirectory;
846-
if (useSyntheticPackage) {
847-
outputDirectory = fileSystem.directory(
848-
projectDirectory != null
849-
? _getAbsoluteProjectPath(_syntheticL10nPackagePath(fileSystem), projectDirectory)
850-
: _syntheticL10nPackagePath(fileSystem),
851-
);
852-
} else {
853-
outputDirectory = fileSystem.directory(
854-
projectDirectory != null
855-
? _getAbsoluteProjectPath(outputPathString, projectDirectory)
856-
: outputPathString,
857-
);
858-
}
859-
return outputDirectory;
823+
return fileSystem.directory(
824+
projectDirectory != null
825+
? _getAbsoluteProjectPath(outputPathString, projectDirectory)
826+
: outputPathString,
827+
);
860828
}
861829

862830
/// Sets the reference [File] for [templateArbFile].
@@ -1469,22 +1437,6 @@ The plural cases must be one of "=0", "=1", "=2", "zero", "one", "two", "few", "
14691437
throw L10nException('Found syntax errors.');
14701438
}
14711439

1472-
// A pubspec.yaml file is required when using a synthetic package. If it does not
1473-
// exist, create a blank one.
1474-
if (useSyntheticPackage) {
1475-
final Directory syntheticPackageDirectory =
1476-
projectDirectory != null
1477-
? projectDirectory!.childDirectory(_defaultSyntheticPackagePath(_fs))
1478-
: _fs.directory(_defaultSyntheticPackagePath(_fs));
1479-
syntheticPackageDirectory.createSync(recursive: true);
1480-
final File flutterGenPubspec = syntheticPackageDirectory.childFile('pubspec.yaml');
1481-
if (!flutterGenPubspec.existsSync()) {
1482-
flutterGenPubspec.writeAsStringSync(
1483-
useCRLF ? emptyPubspecTemplate.replaceAll('\n', '\r\n') : emptyPubspecTemplate,
1484-
);
1485-
}
1486-
}
1487-
14881440
// Since all validity checks have passed up to this point,
14891441
// write the contents into the directory.
14901442
outputDirectory.createSync(recursive: true);

packages/flutter_tools/lib/src/localizations/localizations_utils.dart

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:yaml/yaml.dart';
88
import '../base/common.dart';
99
import '../base/file_system.dart';
1010
import '../base/logger.dart';
11-
import '../features.dart';
1211
import '../runner/flutter_command.dart';
1312
import 'gen_l10n_types.dart';
1413
import 'language_subtag_registry.dart';
@@ -340,7 +339,6 @@ class LocalizationOptions {
340339
this.headerFile,
341340
bool? useDeferredLoading,
342341
this.genInputsAndOutputsList,
343-
bool? syntheticPackage,
344342
this.projectDir,
345343
bool? requiredResourceAttributes,
346344
bool? nullableGetter,
@@ -353,7 +351,6 @@ class LocalizationOptions {
353351
outputLocalizationFile = outputLocalizationFile ?? 'app_localizations.dart',
354352
outputClass = outputClass ?? 'AppLocalizations',
355353
useDeferredLoading = useDeferredLoading ?? false,
356-
syntheticPackage = syntheticPackage ?? !featureFlags.isExplicitPackageDependenciesEnabled,
357354
requiredResourceAttributes = requiredResourceAttributes ?? false,
358355
nullableGetter = nullableGetter ?? true,
359356
format = format ?? true,
@@ -415,12 +412,6 @@ class LocalizationOptions {
415412
/// This path is relative to [arbDir].
416413
final String? genInputsAndOutputsList;
417414

418-
/// The `--synthetic-package` argument.
419-
///
420-
/// Whether to generate the Dart localization files in a synthetic package
421-
/// or in a custom directory.
422-
final bool syntheticPackage;
423-
424415
/// The `--project-dir` argument.
425416
///
426417
/// This path is relative to [arbDir].
@@ -481,7 +472,6 @@ LocalizationOptions parseLocalizationsOptionsFromYAML({
481472
required Logger logger,
482473
required FileSystem fileSystem,
483474
required String defaultArbDir,
484-
required bool defaultSyntheticPackage,
485475
}) {
486476
final String contents = file.readAsStringSync();
487477
if (contents.trim().isEmpty) {
@@ -518,8 +508,6 @@ LocalizationOptions parseLocalizationsOptionsFromYAML({
518508
headerFile: _tryReadFilePath(yamlNode, 'header-file', logger, fileSystem),
519509
useDeferredLoading: _tryReadBool(yamlNode, 'use-deferred-loading', logger),
520510
preferredSupportedLocales: _tryReadStringList(yamlNode, 'preferred-supported-locales', logger),
521-
syntheticPackage:
522-
_tryReadBool(yamlNode, 'synthetic-package', logger) ?? defaultSyntheticPackage,
523511
requiredResourceAttributes: _tryReadBool(yamlNode, 'required-resource-attributes', logger),
524512
nullableGetter: _tryReadBool(yamlNode, 'nullable-getter', logger),
525513
format: _tryReadBool(yamlNode, 'format', logger),
@@ -535,15 +523,6 @@ LocalizationOptions parseLocalizationsOptionsFromCommand({
535523
required FlutterCommand command,
536524
required String defaultArbDir,
537525
}) {
538-
// TODO(matanlurey): Remove as part of https://github.com/flutter/flutter/issues/102983.
539-
final bool syntheticPackage;
540-
if (command.argResults!.wasParsed('synthetic-package')) {
541-
// If provided explicitly, use the explicit value.
542-
syntheticPackage = command.boolArg('synthetic-package');
543-
} else {
544-
// Otherwise, inherit from whatever the reverse of flutter config --explicit-package-dependencies.
545-
syntheticPackage = !featureFlags.isExplicitPackageDependenciesEnabled;
546-
}
547526
return LocalizationOptions(
548527
arbDir: command.stringArg('arb-dir') ?? defaultArbDir,
549528
outputDir: command.stringArg('output-dir'),
@@ -555,7 +534,6 @@ LocalizationOptions parseLocalizationsOptionsFromCommand({
555534
headerFile: command.stringArg('header-file'),
556535
useDeferredLoading: command.boolArg('use-deferred-loading'),
557536
genInputsAndOutputsList: command.stringArg('gen-inputs-and-outputs-list'),
558-
syntheticPackage: syntheticPackage,
559537
projectDir: command.stringArg('project-dir'),
560538
requiredResourceAttributes: command.boolArg('required-resource-attributes'),
561539
nullableGetter: command.boolArg('nullable-getter'),

packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class FakePub extends Fake implements Pub {
3333
required FlutterProject project,
3434
bool upgrade = false,
3535
bool offline = false,
36-
bool generateSyntheticPackage = false,
37-
bool generateSyntheticPackageForExample = false,
3836
String? flutterRootOverride,
3937
bool checkUpToDate = false,
4038
bool shouldSkipThirdPartyGenerator = true,

packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,6 @@ class FakePub extends Fake implements Pub {
928928
required FlutterProject project,
929929
bool upgrade = false,
930930
bool offline = false,
931-
bool generateSyntheticPackage = false,
932931
String? flutterRootOverride,
933932
bool checkUpToDate = false,
934933
bool shouldSkipThirdPartyGenerator = true,

packages/flutter_tools/test/commands.shard/hermetic/pub_test.dart

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ import 'package:flutter_tools/src/base/logger.dart';
1111
import 'package:flutter_tools/src/cache.dart';
1212
import 'package:flutter_tools/src/commands/packages.dart';
1313
import 'package:flutter_tools/src/dart/pub.dart';
14-
import 'package:flutter_tools/src/features.dart';
1514
import 'package:flutter_tools/src/project.dart';
16-
import 'package:flutter_tools/src/runner/flutter_command.dart';
1715
import 'package:test/fake.dart';
1816
import 'package:unified_analytics/unified_analytics.dart';
1917

2018
import '../../src/context.dart';
21-
import '../../src/fakes.dart';
2219
import '../../src/package_config.dart';
2320
import '../../src/test_flutter_command_runner.dart';
2421

@@ -38,15 +35,6 @@ void main() {
3835
late FakePub pub;
3936
late BufferLogger logger;
4037

41-
// TODO(matanlurey): Remove after `flutter_gen` is removed.
42-
// See https://github.com/flutter/flutter/issues/102983 for details.
43-
FeatureFlags disableExplicitPackageDependencies() {
44-
return TestFeatureFlags(
45-
// ignore: avoid_redundant_argument_values
46-
isExplicitPackageDependenciesEnabled: false,
47-
);
48-
}
49-
5038
setUp(() {
5139
Cache.disableLocking();
5240
fileSystem = MemoryFileSystem.test();
@@ -292,53 +280,6 @@ void main() {
292280
FileSystem: () => fileSystem,
293281
},
294282
);
295-
296-
testUsingContext(
297-
'pub get triggers localizations generation when generate: true',
298-
() async {
299-
final File pubspecFile = fileSystem.currentDirectory.childFile('pubspec.yaml')..createSync();
300-
pubspecFile.writeAsStringSync('''
301-
name: my_app
302-
flutter:
303-
generate: true
304-
''');
305-
fileSystem.currentDirectory.childFile('l10n.yaml')
306-
..createSync()
307-
..writeAsStringSync('''
308-
arb-dir: lib/l10n
309-
''');
310-
final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb'))
311-
..createSync(recursive: true);
312-
arbFile.writeAsStringSync('''
313-
{
314-
"helloWorld": "Hello, World!",
315-
"@helloWorld": {
316-
"description": "Sample description"
317-
}
318-
}
319-
''');
320-
321-
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
322-
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
323-
324-
await commandRunner.run(<String>['get']);
325-
final FlutterCommandResult result = await command.runCommand();
326-
327-
expect(result.exitStatus, ExitStatus.success);
328-
final Directory outputDirectory = fileSystem.directory(
329-
fileSystem.path.join('.dart_tool', 'flutter_gen', 'gen_l10n'),
330-
);
331-
expect(outputDirectory.existsSync(), true);
332-
expect(outputDirectory.childFile('app_localizations_en.dart').existsSync(), true);
333-
expect(outputDirectory.childFile('app_localizations.dart').existsSync(), true);
334-
},
335-
overrides: <Type, Generator>{
336-
Pub: () => pub,
337-
ProcessManager: () => FakeProcessManager.any(),
338-
FileSystem: () => fileSystem,
339-
FeatureFlags: disableExplicitPackageDependencies,
340-
},
341-
);
342283
}
343284

344285
class FakePub extends Fake implements Pub {
@@ -353,7 +294,6 @@ class FakePub extends Fake implements Pub {
353294
required PubContext context,
354295
required String command,
355296
bool touchesPackageConfig = false,
356-
bool generateSyntheticPackage = false,
357297
PubOutputMode outputMode = PubOutputMode.all,
358298
}) async {
359299
if (project != null) {

packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ class _FakePub extends Fake implements Pub {
382382
required PubContext context,
383383
required String command,
384384
bool touchesPackageConfig = false,
385-
bool generateSyntheticPackage = false,
386385
PubOutputMode outputMode = PubOutputMode.all,
387386
}) async {
388387
if (project == null) {
@@ -406,8 +405,6 @@ class _FakePub extends Fake implements Pub {
406405
required FlutterProject project,
407406
bool upgrade = false,
408407
bool offline = false,
409-
bool generateSyntheticPackage = false,
410-
bool generateSyntheticPackageForExample = false,
411408
String? flutterRootOverride,
412409
bool checkUpToDate = false,
413410
bool shouldSkipThirdPartyGenerator = true,

packages/flutter_tools/test/commands.shard/permeable/build_aar_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ class FakePub extends Fake implements Pub {
577577
required FlutterProject project,
578578
bool upgrade = false,
579579
bool offline = false,
580-
bool generateSyntheticPackage = false,
581580
String? flutterRootOverride,
582581
bool checkUpToDate = false,
583582
bool shouldSkipThirdPartyGenerator = true,

0 commit comments

Comments
 (0)