Migrate localizations and generate_synthetic_packages to null safety (#83310)
This commit is contained in:
parent
6b6b71ffa6
commit
2bf0627dea
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import '../../base/file_system.dart';
|
import '../../base/file_system.dart';
|
||||||
import '../../convert.dart';
|
import '../../convert.dart';
|
||||||
import '../../localizations/gen_l10n.dart';
|
import '../../localizations/gen_l10n.dart';
|
||||||
@ -69,15 +67,19 @@ class GenerateLocalizationsTarget extends Target {
|
|||||||
final Map<String, Object> dependencies = json.decode(
|
final Map<String, Object> dependencies = json.decode(
|
||||||
environment.buildDir.childFile(_kDependenciesFileName).readAsStringSync()
|
environment.buildDir.childFile(_kDependenciesFileName).readAsStringSync()
|
||||||
) as Map<String, Object>;
|
) as Map<String, Object>;
|
||||||
|
final List<Object?>? inputs = dependencies['inputs'] as List<Object?>?;
|
||||||
|
final List<Object?>? outputs = dependencies['outputs'] as List<Object?>?;
|
||||||
final Depfile depfile = Depfile(
|
final Depfile depfile = Depfile(
|
||||||
<File>[
|
<File>[
|
||||||
configFile,
|
configFile,
|
||||||
for (dynamic inputFile in dependencies['inputs'] as List<dynamic>)
|
if (inputs != null)
|
||||||
environment.fileSystem.file(inputFile)
|
for (Object inputFile in inputs.whereType<Object>())
|
||||||
|
environment.fileSystem.file(inputFile)
|
||||||
],
|
],
|
||||||
<File>[
|
<File>[
|
||||||
for (dynamic outputFile in dependencies['outputs'] as List<dynamic>)
|
if (outputs != null)
|
||||||
environment.fileSystem.file(outputFile)
|
for (Object outputFile in outputs.whereType<Object>())
|
||||||
|
environment.fileSystem.file(outputFile)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
depfileService.writeToFile(
|
depfileService.writeToFile(
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
import 'package:yaml/yaml.dart';
|
import 'package:yaml/yaml.dart';
|
||||||
|
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
@ -14,8 +11,8 @@ import '../build_system/build_system.dart';
|
|||||||
import '../build_system/targets/localizations.dart';
|
import '../build_system/targets/localizations.dart';
|
||||||
|
|
||||||
Future<void> generateLocalizationsSyntheticPackage({
|
Future<void> generateLocalizationsSyntheticPackage({
|
||||||
@required Environment environment,
|
required Environment environment,
|
||||||
@required BuildSystem buildSystem,
|
required BuildSystem buildSystem,
|
||||||
}) async {
|
}) async {
|
||||||
assert(environment != null);
|
assert(environment != null);
|
||||||
assert(buildSystem != null);
|
assert(buildSystem != null);
|
||||||
@ -42,7 +39,7 @@ Future<void> generateLocalizationsSyntheticPackage({
|
|||||||
// it.
|
// it.
|
||||||
if (yamlNode.value != null) {
|
if (yamlNode.value != null) {
|
||||||
final YamlMap yamlMap = yamlNode as YamlMap;
|
final YamlMap yamlMap = yamlNode as YamlMap;
|
||||||
final Object value = yamlMap['synthetic-package'];
|
final Object? value = yamlMap['synthetic-package'];
|
||||||
if (value is! bool && value != null) {
|
if (value is! bool && value != null) {
|
||||||
throwToolExit(
|
throwToolExit(
|
||||||
'Expected "synthetic-package" to have a bool value, '
|
'Expected "synthetic-package" to have a bool value, '
|
||||||
@ -52,8 +49,8 @@ Future<void> generateLocalizationsSyntheticPackage({
|
|||||||
|
|
||||||
// Generate gen_l10n synthetic package only if synthetic-package: true or
|
// Generate gen_l10n synthetic package only if synthetic-package: true or
|
||||||
// synthetic-package is null.
|
// synthetic-package is null.
|
||||||
final bool isSyntheticL10nPackage = value as bool ?? true;
|
final bool? isSyntheticL10nPackage = value as bool?;
|
||||||
if (!isSyntheticL10nPackage) {
|
if (isSyntheticL10nPackage == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,7 +67,7 @@ Future<void> generateLocalizationsSyntheticPackage({
|
|||||||
throwToolExit(
|
throwToolExit(
|
||||||
'Generating synthetic localizations package failed with ${result.exceptions.length} ${pluralize('error', result.exceptions.length)}:'
|
'Generating synthetic localizations package failed with ${result.exceptions.length} ${pluralize('error', result.exceptions.length)}:'
|
||||||
'\n\n'
|
'\n\n'
|
||||||
'${result.exceptions.values.map<Object>((ExceptionMeasurement e) => e.exception).join('\n\n')}',
|
'${result.exceptions.values.map<Object?>((ExceptionMeasurement e) => e.exception).join('\n\n')}',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
|
import 'package:flutter_tools/src/artifacts.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/logger.dart';
|
import 'package:flutter_tools/src/base/logger.dart';
|
||||||
import 'package:flutter_tools/src/build_system/build_system.dart';
|
import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||||
@ -19,7 +18,7 @@ void main() {
|
|||||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||||
final Environment environment = Environment.test(
|
final Environment environment = Environment.test(
|
||||||
fileSystem.currentDirectory,
|
fileSystem.currentDirectory,
|
||||||
artifacts: null,
|
artifacts: Artifacts.test(),
|
||||||
fileSystem: fileSystem,
|
fileSystem: fileSystem,
|
||||||
logger: BufferLogger.test(),
|
logger: BufferLogger.test(),
|
||||||
processManager: FakeProcessManager.any(),
|
processManager: FakeProcessManager.any(),
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
@ -45,7 +44,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
final Completer<void> completer = Completer<void>();
|
final Completer<void> completer = Completer<void>();
|
||||||
final BuildResult exception = BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
|
final BuildResult exception = BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
|
||||||
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null),
|
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), StackTrace.current),
|
||||||
});
|
});
|
||||||
final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) {
|
final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) {
|
||||||
expect(target, const GenerateLocalizationsTarget());
|
expect(target, const GenerateLocalizationsTarget());
|
||||||
@ -94,7 +93,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
final Completer<void> completer = Completer<void>();
|
final Completer<void> completer = Completer<void>();
|
||||||
final BuildResult exception = BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
|
final BuildResult exception = BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
|
||||||
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null),
|
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), StackTrace.current),
|
||||||
});
|
});
|
||||||
final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) {
|
final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) {
|
||||||
expect(target, const GenerateLocalizationsTarget());
|
expect(target, const GenerateLocalizationsTarget());
|
||||||
@ -141,7 +140,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
final Completer<void> completer = Completer<void>();
|
final Completer<void> completer = Completer<void>();
|
||||||
final BuildResult exception = BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
|
final BuildResult exception = BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
|
||||||
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null),
|
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), StackTrace.current),
|
||||||
});
|
});
|
||||||
final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) {
|
final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) {
|
||||||
expect(target, const GenerateLocalizationsTarget());
|
expect(target, const GenerateLocalizationsTarget());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user