Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build_runner/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.10.3-wip

- Bug fix: fix crash when you run `dart run build_runner build` in a
subdirectory of a package.

## 2.10.2

- Bug fix: fix issue with webdev failing due to a modification during a build.
Expand Down
3 changes: 3 additions & 0 deletions build_runner/lib/src/build_plan/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:yaml/yaml.dart';

import '../constants.dart';
import '../io/asset_path_provider.dart';
import '../logging/build_log.dart';

/// The SDK package, we filter this to the core libs and dev compiler
/// resources.
Expand Down Expand Up @@ -67,6 +68,8 @@ class PackageGraph implements AssetPathProvider {
/// Creates a [PackageGraph] for the package whose top level directory lives
/// at [packagePath] (no trailing slash).
static Future<PackageGraph> forPath(String packagePath) async {
buildLog.debug('forPath $packagePath');

/// Read in the pubspec file and parse it as yaml.
final pubspec = File(p.join(packagePath, 'pubspec.yaml'));
if (!pubspec.existsSync()) {
Expand Down
12 changes: 11 additions & 1 deletion build_runner/lib/src/build_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ class BuildRunner {

// Option parsing depends on the package name in `pubspec.yaml`.
// Fortunately, `dart run build_runner` checks that `pubspec.yaml` is
// present and valid, so there must be a `name`.
// present in the current or a parent directory, and that it's valid, so
// there must be a `name`.
//
// Start by changing the current directory to the package root.
while (!File(p.join(Directory.current.path, 'pubspec.yaml')).existsSync()) {
final parent = Directory.current.parent;
if (parent.path == Directory.current.path) {
throw StateError('Missing pubspec.yaml.');
}
Directory.current = parent;
}
final rootPackage =
(loadYaml(File(p.join(p.current, 'pubspec.yaml')).readAsStringSync())
as YamlMap)['name']!
Expand Down
2 changes: 1 addition & 1 deletion build_runner/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: build_runner
version: 2.10.2
version: 2.10.3-wip
description: A build system for Dart code generation and modular compilation.
repository: https://github.com/dart-lang/build/tree/master/build_runner
resolution: workspace
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

@Tags(['integration4'])
library;

import 'package:test/test.dart';

import '../common/common.dart';

void main() async {
test('build command packages and paths', () async {
final pubspecs = await Pubspecs.load();
final tester = BuildRunnerTester(pubspecs);

tester.writeFixturePackage(
FixturePackages.copyBuilder(buildToCache: true, applyToAllPackages: true),
);
tester.writePackage(
name: 'root_pkg',
dependencies: ['build_runner'],
pathDependencies: ['builder_pkg'],
files: {'lib/a.txt': 'a'},
);

// Runs in a subdirectory of the package.
await tester.run('root_pkg/lib', 'dart run build_runner build');
expect(tester.readFileTree('root_pkg/.dart_tool/build/generated'), {
'root_pkg/lib/a.txt.copy': 'a',
});
});
}
4 changes: 4 additions & 0 deletions build_test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.5.3-wip

- Use `build_runner` 2.10.3.

## 3.5.2

- Use `build_runner` 2.10.2.
Expand Down
4 changes: 2 additions & 2 deletions build_test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: build_test
description: Utilities for writing unit tests of Builders.
version: 3.5.2
version: 3.5.3-wip
repository: https://github.com/dart-lang/build/tree/master/build_test
resolution: workspace

Expand All @@ -10,7 +10,7 @@ environment:
dependencies:
build: ^4.0.0
build_config: ^1.0.0
build_runner: '2.10.2'
build_runner: '2.10.3-wip'
built_collection: ^5.1.1
crypto: ^3.0.0
glob: ^2.0.0
Expand Down