build_config 0.1.0
build_config: ^0.1.0 copied to clipboard
Support for parsing `build.yaml` configuration.
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
Builderclass definition. - import: Required. The import uri that should be used to import the library
containing the
Builderclass. This should always be apackage: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 typedefBuilder 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
buildExtensionsmaps from eachBuilderinbuilder_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"]}