build_config 0.1.0

Customizing builds

Customizing the build behavior of a package is done by creating a build.yaml file, which describes your configuration.

Defining Builders to apply to dependents (similar to transformers)

If users of your package need to apply some code generation to their package, then you can define Builders and have those applied to packages with a dependency on yours.

Exposed Builders are configured in the builders section of the build.yaml. This is a map of builder names to configuration. Each builder config may contain the following keys:

  • target: The name of the target which defines contains the Builder class definition.
  • import: Required. The import uri that should be used to import the library containing the Builder class. This should always be a package: uri.
  • builder_factories: A List<String> which contains the names of the top-level methods in the imported library which are a function fitting the typedef Builder factoryName(List<String> args).
  • build_extensions: Required. A map from input extension to the list of output extensions that may be created for that input. This must match the merged buildExtensions maps from each Builder in builder_factories.

Example builders config:

targets:
  # The target containing the builder sources.
  _my_builder: # By convention, this is private
    sources:
      - "lib/src/builder/**/*.dart"
      - "lib/builder.dart"
    dependencies:
      - "build"
      - "source_gen"
builders:
  # The actual builder config.
  my_builder:
    target: ":_my_builder"
    import: "package:my_package/builder.dart"
    builder_factories: ["myBuilder"]
    build_extensions: {".dart": [".my_package.dart"]}

0.1.0

  • Initial release - pulled from package:dazel. Updated to support build_extensions instead of input_extension and output_extensions.

1. Depend on it

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

dependencies:
  build_config: "^0.1.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:build_config/build_config.dart';
Version Uploaded Documentation Archive
0.1.0 Nov 14, 2017 Go to the documentation of build_config 0.1.0 Download build_config 0.1.0 archive

Platforms

About

Support for parsing `build.yaml` configuration.

Author

Dart Team

Homepage

github.com/dart-lang/build

Documentation

www.dartdocs.org/documentation/build_config/0.1.0/

Uploader

nbosch@google.com
jakemac@google.com

License

BSD (LICENSE)

Published

Nov 14, 2017