Skip to content

Commit

Permalink
Move shorebird.yaml processing to assets.dart to update the file on copy
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanoltman committed Jan 21, 2025
1 parent d60f7e6 commit aace41a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
15 changes: 15 additions & 0 deletions packages/flutter_tools/lib/src/build_system/targets/assets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import '../../convert.dart';
import '../../dart/package_map.dart';
import '../../devfs.dart';
import '../../flutter_manifest.dart';
import '../../globals.dart' as globals show platform;
import '../../shorebird/shorebird_yaml.dart';
import '../build_system.dart';
import '../depfile.dart';
import '../exceptions.dart';
Expand Down Expand Up @@ -179,6 +181,19 @@ Future<Depfile> copyAssets(
}
if (doCopy) {
await (content.file as File).copy(file.path);
if (file.basename == 'shorebird.yaml') {
try {
updateShorebirdYaml(
environment.defines[kFlavor],
file.path,
environment: globals.platform.environment,
);
} on Exception catch (error) {
throw Exception(
'Failed to generate shorebird configuration. Error: $error',
);
}
}
}
} else {
await file.writeAsBytes(await entry.value.content.contentsAsBytes());
Expand Down
19 changes: 1 addition & 18 deletions packages/flutter_tools/lib/src/build_system/targets/macos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import '../../base/file_system.dart';
import '../../base/io.dart';
import '../../base/process.dart';
import '../../build_info.dart';
import '../../globals.dart' as globals show platform, xcode;
import '../../globals.dart' as globals show xcode;
import '../../reporting/reporting.dart';
import '../../shorebird/shorebird_yaml.dart';
import '../build_system.dart';
import '../depfile.dart';
import '../exceptions.dart';
Expand Down Expand Up @@ -684,22 +683,6 @@ class ReleaseMacOSBundleFlutterAssets extends MacOSBundleFlutterAssets {
bool buildSuccess = true;
try {
await super.build(environment);
final ResolvedFiles resolvedOutputs = resolveOutputs(environment);
for (final File outputSource in resolvedOutputs.sources) {
if (outputSource.basename == 'shorebird.yaml') {
try {
updateShorebirdYaml(
environment.defines[kFlavor],
outputSource.path,
environment: globals.platform.environment,
);
} on Exception catch (error) {
throw Exception(
'Failed to generate shorebird configuration. Error: $error',
);
}
}
}
} catch (_) { // ignore: avoid_catches_without_on_clauses
buildSuccess = false;
rethrow;
Expand Down

0 comments on commit aace41a

Please sign in to comment.