mirror of
https://github.com/flutter/packages.git
synced 2025-08-06 17:28:42 +08:00
[flutter_plugin_tools] Introduce a class for packages (#4252)
Packages are the primary conceptual object in the tool, but currently they are represented simply as Directory (or occasionally a path string). This introduces an object for packages and: - moves a number of existing utility methods into it - sweeps the code for the obvious cases of using `Directory` to represent a package, especially in method signatures and migrates them - notes a few places where we should migrate later, to avoid ballooning the size of the PR There are no doubt other cases not caught in the sweep, but this gives us a foundation both for new code, and to migrate incrementally toward as we find existing code that was missed.
This commit is contained in:
@ -11,6 +11,7 @@ import 'common/core.dart';
|
||||
import 'common/package_looping_command.dart';
|
||||
import 'common/plugin_utils.dart';
|
||||
import 'common/process_runner.dart';
|
||||
import 'common/repository_package.dart';
|
||||
|
||||
/// Key for APK.
|
||||
const String _platformFlagApk = 'apk';
|
||||
@ -96,7 +97,7 @@ class BuildExamplesCommand extends PackageLoopingCommand {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PackageResult> runForPackage(Directory package) async {
|
||||
Future<PackageResult> runForPackage(RepositoryPackage package) async {
|
||||
final List<String> errors = <String>[];
|
||||
|
||||
final Iterable<_PlatformDetails> requestedPlatforms = _platforms.entries
|
||||
@ -126,9 +127,9 @@ class BuildExamplesCommand extends PackageLoopingCommand {
|
||||
}
|
||||
print('');
|
||||
|
||||
for (final Directory example in getExamplesForPlugin(package)) {
|
||||
for (final RepositoryPackage example in package.getExamples()) {
|
||||
final String packageName =
|
||||
getRelativePosixPath(example, from: packagesDir);
|
||||
getRelativePosixPath(example.directory, from: packagesDir);
|
||||
|
||||
for (final _PlatformDetails platform in buildPlatforms) {
|
||||
String buildPlatform = platform.label;
|
||||
@ -149,7 +150,7 @@ class BuildExamplesCommand extends PackageLoopingCommand {
|
||||
}
|
||||
|
||||
Future<bool> _buildExample(
|
||||
Directory example,
|
||||
RepositoryPackage example,
|
||||
String flutterBuildType, {
|
||||
List<String> extraBuildFlags = const <String>[],
|
||||
}) async {
|
||||
@ -164,7 +165,7 @@ class BuildExamplesCommand extends PackageLoopingCommand {
|
||||
if (enableExperiment.isNotEmpty)
|
||||
'--enable-experiment=$enableExperiment',
|
||||
],
|
||||
workingDir: example,
|
||||
workingDir: example.directory,
|
||||
);
|
||||
return exitCode == 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user