build_daemon 2.1.0

This package provides support for running builds in a daemon.

2.1.0 #

  • Added optional DefaultBuildTarget.buildFilters field.

2.0.0 #

  • Create a public entrypoint for backend implementations of the daemon protocol.
    • Refer to lib/daemon.dart.
  • Update client connect method to now take an optional buildMode. The default mode is auto in which builds will automatically occur on changes. The alternative mode is manual in which builds will only occur when triggered with the client startBuild method.
  • Add enum of build modes to constants.dart.

1.1.0 #

  • Add failureType to ShutdownNotification.

1.0.0 #

  • Changed the ServerLog class to have separate level, message, loggerName, error, and stackTrace fields.
  • Accept file change notifications as Stream<List<WatchEvent>> instead of Stream<WatchEvent>. This allows file change notifications to be sent as batches of simultaneous changes, preventing over-triggering of builds.

0.6.1 #

  • Use HttpMultiServer to better support IPv6 and IPv4 workflows.

0.6.0 #

  • Add retry logic to the state file helpers runningVersion and currentOptions.
  • DaemonBuilder is now an abstract class.
  • Significantly increase doc comment coverage.

0.5.1 #

  • Support shutting down the daemon with a notification.

0.5.0 #

  • Add OutputLocation to DefaultBuildTarget.

0.4.2 #

  • Enable configuring the environment for the daemon.

0.4.1 #

  • Support closing a daemon client.
  • Fix a null set bug in the build target manager.

0.4.0 #

  • Replace the client log stream with an optional logHandler. This simplifies the logging logic and prevents the need for the client to print to stdio.

0.3.0 #

  • Forward daemon output while starting up / connecting.

0.2.3 #

  • Shutdown the daemon if no client connects within 30 seconds.

0.2.2 #

  • Resolve client path issues with running on Windows.

0.2.1 #

  • Resolve issues with running on Windows.
    • Close the lock file prior to deleting it.
    • Properly join paths and escape the workspace.

0.2.0 #

  • Support custom build results.
  • Options are no longer dynamic and are provided upon connecting.
  • Report OptionsSkew.
  • Prefix build daemon directory with username.
  • Forward filesystem changes to daemon builder.
  • Support custom build targets.

0.0.1 #

  • Initial Build Daemon support.


// Copyright (c) 2019, 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.

import 'dart:io';
import 'dart:math';

import 'package:build_daemon/client.dart';
import 'package:build_daemon/data/build_target.dart';
import 'package:path/path.dart' as p;

void main(List<String> args) async {
  BuildDaemonClient client;
  var workingDirectory =
      p.normalize(p.join(Directory.current.path + '/../example'));

  try {
    // First we connect to the daemon. This will start one if one is not
    // currently running.
    client = await BuildDaemonClient.connect(
        logHandler: print);
  } catch (e) {
    if (e is VersionSkew) {
      print('Version skew. Please disconnect all other clients '
          'before trying to start a new one.');
    } else if (e is OptionsSkew) {
      print('Options skew. Please disconnect all other clients '
          'before trying to start a new one.');
    } else {
      print('Unexpected error: $e');

  if (client == null) throw Exception('Error connecting');
  print('Connected to Dart Build Daemon');

  // Next we register a build target (directory) to build.
  // Note this will not cause a build to occur unless there are relevant file
  // changes.
  if (Random().nextBool()) {
    client.registerBuildTarget(DefaultBuildTarget((b) => b = 'web'
      ..outputLocation = OutputLocation((b) => b
        ..output = 'web_output'
        ..useSymlinks = false
        ..hoist = true).toBuilder()
    print('Registered example web target...');
  } else {
    client.registerBuildTarget(DefaultBuildTarget((b) => b = 'test'
      ..outputLocation = OutputLocation((b) => b
        ..output = 'test_output'
        ..useSymlinks = true
        ..hoist = false).toBuilder()));

    print('Registered test target...');

  // Handle events coming from the daemon.
  client.buildResults.listen((status) => print('BUILD STATUS: $status'));

  // Force a build of all registered targets.

  await client.finished;

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  build_daemon: ^2.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:build_daemon/change_provider.dart';
import 'package:build_daemon/client.dart';
import 'package:build_daemon/constants.dart';
import 'package:build_daemon/daemon.dart';
import 'package:build_daemon/daemon_builder.dart';
import 'package:build_daemon/data/build_request.dart';
import 'package:build_daemon/data/build_request.g.dart';
import 'package:build_daemon/data/build_status.dart';
import 'package:build_daemon/data/build_status.g.dart';
import 'package:build_daemon/data/build_target.dart';
import 'package:build_daemon/data/build_target.g.dart';
import 'package:build_daemon/data/build_target_request.dart';
import 'package:build_daemon/data/build_target_request.g.dart';
import 'package:build_daemon/data/serializers.dart';
import 'package:build_daemon/data/serializers.g.dart';
import 'package:build_daemon/data/server_log.dart';
import 'package:build_daemon/data/server_log.g.dart';
import 'package:build_daemon/data/shutdown_notification.dart';
import 'package:build_daemon/data/shutdown_notification.g.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Sep 13, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21


Detected platforms: Flutter, other

Platform components identified in package: io.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
built_collection ^4.1.0 4.2.2
built_value ^6.3.0 6.7.1
http_multi_server ^2.0.0 2.1.0
logging ^0.11.0 0.11.3+2
package_resolver ^1.0.6 1.0.10
path ^1.6.2 1.6.4
pedantic ^1.0.0 1.8.0+1
pool ^1.3.6 1.4.0
shelf ^0.7.4 0.7.5
shelf_web_socket ^0.2.2+4 0.2.3
stream_transform ^0.0.14+1 0.0.19
watcher ^0.9.7 0.9.7+12
web_socket_channel ^1.0.9 1.0.15
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
fixnum 0.10.9
http 0.12.0+2
http_parser 3.1.3
matcher 0.12.5
meta 1.1.7
package_config 1.1.0
quiver 2.0.5
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
build_runner ^1.0.0
built_value_generator ^6.2.0
mockito ^4.0.0
test ^1.3.3
test_descriptor ^1.1.1
uuid ^2.0.0