Skip to content

Commit 4069de3

Browse files
authored
[native_assets_builder] Don't change outputDirectory if assetsForLinking changes (#1746)
#1643 accidentally made the output directory of link hooks change when different assets are passed in for linking.
1 parent 4ce4816 commit 4069de3

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart

+5-3
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,15 @@ class NativeAssetsBuildRunner {
232232
buildMode: buildMode,
233233
packageName: package.name,
234234
packageRoot: packageLayout.packageRoot(package.name),
235-
)
236-
..setupLinkConfig(
237-
assets: buildResult.encodedAssetsForLinking[package.name] ?? []);
235+
);
238236

239237
final (buildDirUri, outDirUri, outDirSharedUri) = await _setupDirectories(
240238
Hook.link, packageLayout, configBuilder, package);
241239

240+
configBuilder.setupLinkConfig(
241+
assets: buildResult.encodedAssetsForLinking[package.name] ?? [],
242+
);
243+
242244
File? resourcesFile;
243245
if (resourceIdentifiers != null) {
244246
resourcesFile = File.fromUri(buildDirUri.resolve('resources.json'));

pkgs/native_assets_cli/lib/src/config.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,13 @@ sealed class HookConfigBuilder {
135135
/// assumed the output directory has not been set yet.
136136
String computeChecksum() {
137137
if (json.containsKey(_outDirConfigKey) ||
138-
json.containsKey(_outDirSharedConfigKey)) {
138+
json.containsKey(_outDirSharedConfigKey) ||
139+
json.containsKey(_assetsKey)) {
139140
// The bundling tools would first calculate the checksum, create an output
140141
// directory and then call [BuildConfigBuilder.setupBuildRunConfig] &
141142
// [LinkConfigBuilder.setupLinkRunConfig].
143+
// The output directory should not depend on the assets passed in for
144+
// linking.
142145
throw StateError('The checksum should be generated before setting '
143146
'up the run configuration');
144147
}

0 commit comments

Comments
 (0)