Skip to content

Commit 82887c2

Browse files
authored
[native_assets_cli] Deprecate metadata (#1341)
We might not address this issue fully before stable. * #1251 But we're quite sure to remove the current metadata API, so deprecate it.
1 parent 21f7c3d commit 82887c2

File tree

10 files changed

+33
-2
lines changed

10 files changed

+33
-2
lines changed

pkgs/native_assets_builder/test_data/package_reading_metadata/hook/build.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// ignore_for_file: deprecated_member_use
6+
57
import 'package:native_assets_cli/native_assets_cli.dart';
68

79
void main(List<String> args) async {

pkgs/native_assets_builder/test_data/package_with_metadata/hook/build.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:native_assets_cli/native_assets_cli.dart';
66

77
void main(List<String> arguments) async {
88
await build(arguments, (config, output) async {
9+
// ignore: deprecated_member_use
910
output.addMetadata({
1011
'some_key': 'some_value',
1112
'some_int': 3,

pkgs/native_assets_cli/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 0.7.2-wip
22

3-
- Nothing yet.
3+
- Deprecate metadata concept.
44

55
## 0.7.1
66

pkgs/native_assets_cli/lib/src/api/build_config.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import 'asset.dart';
1717
import 'build.dart';
1818
import 'build_mode.dart';
1919
import 'build_output.dart';
20+
import 'deprecation_messages.dart';
2021
import 'hook_config.dart';
2122
import 'ios_sdk.dart';
2223
import 'link_mode_preference.dart';
@@ -41,6 +42,7 @@ abstract final class BuildConfig implements HookConfig {
4142
///
4243
/// Not available during a [dryRun]. Will throw a [StateError] if accessed
4344
/// during a [dryRun].
45+
@Deprecated(metadataDeprecation)
4446
Object? metadatum(String packageName, String key);
4547

4648
/// Whether link hooks will be run after the build hooks.
@@ -106,6 +108,7 @@ abstract final class BuildConfig implements HookConfig {
106108
///
107109
/// Parameter [dependencyMetadata] must be a nested map `{'packageName' :
108110
/// {'key' : 'value'}}` where `packageName` and `key` correspond to the
111+
// ignore: deprecated_member_use_from_same_package
109112
/// parameters in [metadatum].
110113
factory BuildConfig.build({
111114
required Uri outputDirectory,
@@ -120,6 +123,7 @@ abstract final class BuildConfig implements HookConfig {
120123
int? targetAndroidNdkApi,
121124
CCompilerConfig? cCompiler,
122125
required LinkModePreference linkModePreference,
126+
@Deprecated(metadataDeprecation)
123127
Map<String, Map<String, Object>>? dependencyMetadata,
124128
Iterable<String>? supportedAssetTypes,
125129
required bool linkingEnabled,

pkgs/native_assets_cli/lib/src/api/build_output.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import 'asset.dart';
2020
import 'build.dart';
2121
import 'build_config.dart';
2222
import 'builder.dart';
23+
import 'deprecation_messages.dart';
2324
import 'hook_config.dart';
2425
import 'link.dart';
2526
import 'linker.dart';
@@ -96,12 +97,13 @@ abstract final class BuildOutput {
9697
///
9798
/// Metadata can be passed to build hook invocations of dependent packages. It
9899
/// must be provided to the constructor as [metadata], or added later with
100+
// ignore: deprecated_member_use_from_same_package
99101
/// [addMetadatum] and [addMetadata].
100102
factory BuildOutput({
101103
DateTime? timestamp,
102104
Iterable<Asset>? assets,
103105
Iterable<Uri>? dependencies,
104-
Map<String, Object>? metadata,
106+
@Deprecated(metadataDeprecation) Map<String, Object>? metadata,
105107
}) =>
106108
HookOutputImpl(
107109
timestamp: timestamp,
@@ -139,10 +141,12 @@ abstract final class BuildOutput {
139141

140142
/// Adds metadata to be passed to build hook invocations of dependent
141143
/// packages.
144+
@Deprecated(metadataDeprecation)
142145
void addMetadatum(String key, Object value);
143146

144147
/// Adds metadata to be passed to build hook invocations of dependent
145148
/// packages.
149+
@Deprecated(metadataDeprecation)
146150
void addMetadata(Map<String, Object> metadata);
147151

148152
/// The version of [BuildOutput].

pkgs/native_assets_cli/lib/src/api/builder.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
15
import 'package:logging/logging.dart';
26

37
import 'build_config.dart';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
const metadataDeprecation = '''
6+
Metadata will be reworked to merge concepts with assets.
7+
If you're currently using metadata, please report your use case in the tracking
8+
issue: https://github.com/dart-lang/native/issues/1251.
9+
''';

pkgs/native_assets_cli/lib/src/api/linker.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
15
import 'package:logging/logging.dart';
26

37
import 'build_output.dart';

pkgs/native_assets_cli/test/api/build_config_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// ignore_for_file: deprecated_member_use_from_same_package
6+
57
import 'dart:io';
68

79
import 'package:native_assets_cli/native_assets_cli.dart';

pkgs/native_assets_cli/test/api/build_output_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void main() {
4141
dependencies: [
4242
Uri.file('path/to/file.ext'),
4343
],
44+
// ignore: deprecated_member_use_from_same_package
4445
metadata: {
4546
'key': 'value',
4647
},

0 commit comments

Comments
 (0)