Skip to content

Commit 0d95c36

Browse files
authored
[flutter_tools] Setup Pub Workspace and package structure for flutter_tools sub-packages (flutter#190733)
Part of the tool extensibility prototype effort. Establishes the Pub Workspace root in `packages/flutter_tools/pubspec.yaml` and introduces the sub-package hierarchy: - `packages/flutter_tools_core` - `packages/flutter_tools_extension` - `packages/flutter_tools_extension_linux_prototype` Includes unit test coverage verifying workspace configuration in `test/general.shard/pub_workspace_test.dart`. Part of flutter#190745 Part of flutter#190755 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 05ee849 commit 0d95c36

9 files changed

Lines changed: 174 additions & 1 deletion

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/// Core data structures, contracts, and host-side abstractions for Flutter
6+
/// tools extensibility.
7+
///
8+
/// This library provides platform-agnostic representations of devices,
9+
/// diagnostic validators, project templates, configuration flags, and plugin
10+
/// bindings shared across host tools and extension packages.
11+
library flutter_tools_core;
12+
13+
// TODO(bkonyi): export core domain models and contracts.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: flutter_tools_core
2+
description: Core definitions, data models, and host adapters for Flutter tools extensibility.
3+
resolution: workspace
4+
5+
environment:
6+
sdk: ^3.11.0-0
7+
8+
dependencies:
9+
meta: 1.19.0
10+
11+
dev_dependencies:
12+
test: 1.31.1
13+
14+
# PUBSPEC CHECKSUM: ttq919
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/// Generic extension protocol base classes and extension interfaces for Flutter
6+
/// tools extensibility.
7+
///
8+
/// This package defines the platform-agnostic RPC protocol framing, handshake,
9+
/// and service handler interfaces (`DeviceExtension`, `DiagnosticsExtension`,
10+
/// `ConfigurationExtension`, etc.) implemented by extension authors.
11+
library flutter_tools_extension;
12+
13+
// TODO(bkonyi): export extension protocol base classes and service interfaces.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: flutter_tools_extension
2+
description: Protocol interfaces and base implementation for Flutter tools extensions.
3+
resolution: workspace
4+
5+
environment:
6+
sdk: ^3.11.0-0
7+
8+
dependencies:
9+
meta: 1.19.0
10+
flutter_tools_core:
11+
path: ../flutter_tools_core
12+
13+
# PUBSPEC CHECKSUM: foiaro
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/// Prototype Linux platform extension package for Flutter tools extensibility.
6+
///
7+
/// This package encapsulates all Linux-specific device detection, doctor check
8+
/// diagnostics, build handlers, and project templates for the custom Linux
9+
/// extension prototype.
10+
library flutter_tools_extension_linux_prototype;
11+
12+
// TODO(bkonyi): implement prototype Linux extension entrypoint and services.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: flutter_tools_extension_linux_prototype
2+
description: Prototype Linux extension for Flutter tools extensibility.
3+
resolution: workspace
4+
5+
environment:
6+
sdk: ^3.11.0-0
7+
8+
dependencies:
9+
meta: 1.19.0
10+
flutter_tools_core:
11+
path: ../flutter_tools_core
12+
flutter_tools_extension:
13+
path: ../flutter_tools_extension
14+
15+
dev_dependencies:
16+
test: 1.31.1
17+
18+
# PUBSPEC CHECKSUM: i74lku

‎packages/flutter_tools/pubspec.yaml‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ homepage: https://flutter.dev
55
environment:
66
sdk: ^3.11.0-0
77

8+
workspace:
9+
- packages/flutter_tools_core
10+
- packages/flutter_tools_extension
11+
- packages/flutter_tools_extension_linux_prototype
12+
813
dependencies:
914
# To update these, use "flutter update-packages --force-upgrade".
1015
#
@@ -22,6 +27,12 @@ dependencies:
2227
crypto: 3.0.7
2328
ffi: 2.2.0
2429
file: 7.0.1
30+
flutter_tools_core:
31+
path: packages/flutter_tools_core
32+
flutter_tools_extension:
33+
path: packages/flutter_tools_extension
34+
flutter_tools_extension_linux_prototype:
35+
path: packages/flutter_tools_extension_linux_prototype
2536
flutter_template_images: 5.0.0
2637
html: 0.15.6
2738
http: 1.6.0
@@ -129,4 +140,4 @@ dartdoc:
129140
nodoc: true
130141

131142

132-
# PUBSPEC CHECKSUM: d0mren
143+
# PUBSPEC CHECKSUM: abnfae
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_tools/src/base/file_system.dart';
6+
import 'package:flutter_tools/src/globals.dart' as globals;
7+
import 'package:yaml/yaml.dart';
8+
9+
import '../src/common.dart';
10+
11+
void main() {
12+
final FileSystem fs = globals.localFileSystem;
13+
final String flutterToolsRoot = fs.path.join(getFlutterRoot(), 'packages', 'flutter_tools');
14+
const expectedWorkspaceMembers = <String>[
15+
'packages/flutter_tools_core',
16+
'packages/flutter_tools_extension',
17+
'packages/flutter_tools_extension_linux_prototype',
18+
];
19+
20+
group('Flutter Tools Pub Workspace', () {
21+
testWithoutContext('root pubspec.yaml declares all sub-packages in workspace', () {
22+
final File pubspecFile = fs.file(fs.path.join(flutterToolsRoot, 'pubspec.yaml'));
23+
expect(pubspecFile.existsSync(), isTrue);
24+
25+
final Object? yamlContent = loadYaml(pubspecFile.readAsStringSync());
26+
expect(yamlContent, isA<YamlMap>());
27+
final yamlMap = yamlContent! as YamlMap;
28+
29+
expect(yamlMap.containsKey('workspace'), isTrue);
30+
final List<String> workspaceList = (yamlMap['workspace'] as YamlList).cast<String>().toList();
31+
32+
for (final member in expectedWorkspaceMembers) {
33+
expect(workspaceList, contains(member), reason: 'Expected workspace to include $member');
34+
}
35+
});
36+
37+
testWithoutContext('member pubspec.yaml files declare workspace resolution', () {
38+
for (final member in expectedWorkspaceMembers) {
39+
final File memberPubspec = fs.file(fs.path.join(flutterToolsRoot, member, 'pubspec.yaml'));
40+
expect(
41+
memberPubspec.existsSync(),
42+
isTrue,
43+
reason: 'Expected pubspec.yaml to exist for $member',
44+
);
45+
46+
final Object? yamlContent = loadYaml(memberPubspec.readAsStringSync());
47+
expect(yamlContent, isA<YamlMap>());
48+
final yamlMap = yamlContent! as YamlMap;
49+
50+
expect(
51+
yamlMap['resolution'],
52+
equals('workspace'),
53+
reason: 'Expected $member to declare resolution: workspace',
54+
);
55+
}
56+
});
57+
});
58+
}

‎pubspec.lock‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,27 @@ packages:
410410
relative: true
411411
source: path
412412
version: "0.0.0"
413+
flutter_tools_core:
414+
dependency: transitive
415+
description:
416+
path: "packages/flutter_tools/packages/flutter_tools_core"
417+
relative: true
418+
source: path
419+
version: "0.0.0"
420+
flutter_tools_extension:
421+
dependency: transitive
422+
description:
423+
path: "packages/flutter_tools/packages/flutter_tools_extension"
424+
relative: true
425+
source: path
426+
version: "0.0.0"
427+
flutter_tools_extension_linux_prototype:
428+
dependency: transitive
429+
description:
430+
path: "packages/flutter_tools/packages/flutter_tools_extension_linux_prototype"
431+
relative: true
432+
source: path
433+
version: "0.0.0"
413434
frontend_server_client:
414435
dependency: "direct main"
415436
description:

0 commit comments

Comments
 (0)