reflectableBuild function
Implementation
Future<BuildResult> reflectableBuild(List<String> arguments) async {
if (arguments.isEmpty) {
// Globbing may produce an empty argument list, and it might be ok,
// but we should give at least notify the caller.
print('reflectable_builder: No arguments given, exiting.');
return BuildResult(BuildStatus.success, []);
} else {
// TODO(eernst) feature: We should support some customization of
// the settings, e.g., specifying options like `suppress_warnings`.
var options = BuilderOptions(
<String, dynamic>{'entry_points': arguments, 'formatted': true},
isRoot: true);
final builder = ReflectableBuilder(options);
var builders = <BuilderApplication>[
applyToRoot(builder, generateFor: InputSet(include: arguments))
];
PackageGraph packageGraph = await PackageGraph.forThisPackage();
var environment = OverrideableEnvironment(IOEnvironment(packageGraph));
BuildOptions buildOptions = await BuildOptions.create(
LogSubscription(environment),
deleteFilesByDefault: true,
packageGraph: packageGraph,
);
try {
BuildRunner build = await BuildRunner.create(
buildOptions, environment, builders, const {},
isReleaseBuild: false);
BuildResult result = await build.run(const {});
await build.beforeExit();
return result;
} finally {
await buildOptions.logListener.cancel();
}
}
}