pub repository
mirror.p-hatan.irbuild_config
0.2.2+1Support for parsing `build.yaml` configuration.
Readme
Customizing builds
Customizing the build behavior of a package is done by creating a build.yaml
file, which describes your configuration.
Dividing a package into Build targets
When a Builder should be applied to a subset of files in a package the package
can be broken up into multiple 'targets'. Targets are configured in the
targets section of the build.yaml. The key for each target makes up the name
for that target. Targets can be referred to in
'$definingPackageName:$targetname'. When the target name matches the package
name it can also be referred to as just the package name. One target in every
package must use the package name so that consumers will use it by default.
In the build.yaml file this target can be defined with the key $default or
with the name of the package.
Each target may also contain the following keys:
- sources: List of Strings or Map, Optional. The set of files within the
package which make up this target. Files are specified using glob syntax. If a
List of Strings is used they are considered the 'include' globs. If a Map is
used can only have the keys
includeandexclude. Any file which matches any glob inincludeand no globs inexcludeis considered a source of the target. Whenincludeis omitted every file is considered a match. - dependencies: List of Strings, Optional. The targets that this target
depends on. Strings in the format
'$packageName:$targetName'to depend on a target within a package or$packageNameto depend on a package's default target. By default this is all of the package names this package depends on (from thepubspec.yaml). - builders: Map, Optional. See "configuring builders" below.
Configuring Builders applied to your package
Each target can specify a builders key which configures the builders which are
applied to that target. The value is a Map from builder to configuration for
that builder. The key is in the format '$packageName|$builderName'. The
configuration may have the following keys:
- enabled: Boolean, Optional: Whether to apply the builder to this target.
Omit this key if you want the default behavior based on the builder's
auto_applyconfiguration. Builders which are manually applied (auto_apply: none) are only ever used when there is a target specifying the builder withenabled: True. - generate_for: List of String or Map, Optional:. The subset of files within
the target's
sourceswhich should have this Builder applied. Seesourcesconfiguration above for how to configure this. - options: Map, Optional: A free-form map which will be passed to the
Builderas aBuilderOptionswhen it is constructed. Usage varies depending on the particular builder.
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.
The key for a Builder will be normalized so that consumers of the builder can
refer to it in '$definingPackageName|$builderName' format. If the builder name
matches the package name it can also be referred to with just the package name.
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. - auto_apply: Optional. The packages which should have this builder
automatically to applied. Defaults to
'none'The possibilities are:"none": Never apply this Builder unless it is manually configured"dependents": Apply this Builder to the package with a direct dependency on the package exposing the builder."all_packages": Apply this Builder to all packages in the transitive dependency graph."root_package"; Apply this Builder only to the top-level package.
- required_inputs: Optional, list of extensions. If a Builder must see every
input with one or more file extensions they can be specified here and it will
be guaranteed to run after any Builder which might produce an output of that
type. For instance a compiler must run after any Builder which can produce
.dartoutputs or those libraries can't be compiled. This option should be rare. Defaults to an empty list. - is_optional: Optional, boolean. Specifies whether a Builder can be run
lazily, such that it won't execute until one of it's outputs is requested by a
later Builder. This option should be rare. Defaults to
False. - build_to: Optional. The location that generated assets should be output
to. The possibilities are:
"source": Outputs go to the source tree next to their primary inputs."cache": Outputs go to a hidden build cache and won't be published. The default is "cache". If a Builder specifies that it outputs to "source" it will never run on any package other than the root - but does not necessarily need to use the "root_package" value for "auto_apply". If it would otherwise run on a non-root package it will be filtered out.
- defaults: Optional: Default values to apply when a user does not specify
the corresponding key in their
builderssection. May contain the following keys:- generate_for: A list of globs that this Builder should run on as a
subset of the corresponding target, or a map with
includeandexcludelists of globs.
- generate_for: A list of globs that this Builder should run on as a
subset of the corresponding target, or a map with
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"]}
auto_apply: dependents
Publishing build.yaml files
build.yaml configuration should be published to pub with the package and
checked in to source control. Whenever a package is published with a
build.yaml it should mark a dependency on build_config to ensure that
the package consuming the config has a compatible version. Breaking version
changes which do not impact the configuration file format will be clearly marked
in the changelog.
Changelog
0.2.2+1
- Expand support for
package:buildto include version0.12.0.
0.2.2
- Bug fix: Empty build.yaml files no longer fail to parse.
- Allow
$defaultas a target name to get he package name automatically filled in.
0.2.1
- Change the default for
BuilderDefinition.buildTotoBuildTo.cache. Builders which want to operate on the source tree will need to explicitly opt in. Allow this regardless of the value ofautoApplyand the build system will need to filter out the builders that can't run. - By default including any configuration for a Builder within a BuildTarget will enabled that builder.
0.2.0
- Add
build_tooption to Builder configuration. - Add
BuildConfig.fromBuildConfigDirfor cases where the package name and dependencies are already known. - Add
TargetBuilderConfigclass to configure builders applied to specific targets. - Add
TargetBuilderConfigDefaultsclass for Builder authors to provide default configuration. - Add
InputSetand changesourcesandgenerate_forto use it. - Remove
BuildTarget.isDefaultand related config parsing. The default will be determined by the target which matches the package name. - Normalize Target and Builder names so they are scoped to the package they are defined in.
Breaking
- Remove
BuildConfigSetclass. This was unused. - Hide
Pubspecclass. ConstructBuildConfiginstances with a package path rather than an already createdPubspecinstance.
0.1.1
- Add
auto_applyoption to Builder configuration. - Add
required_inputsoption to Builder configuration. - Add
is_optionaloption to Builder configuration.
0.1.0
- Initial release - pulled from
package:dazel. Updated to supportbuild_extensionsinstead ofinput_extensionandoutput_extensions.
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add build_configpubspec.yaml
name: build_config
version: 0.2.2+1
description: Support for parsing `build.yaml` configuration.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/build
environment:
sdk: '>=1.22.1 <2.0.0'
dependencies:
build: ">=0.11.2 <0.13.0"
meta: ^1.1.0
path: ^1.4.0
yaml: ^2.1.11
dev_dependencies:
test: ^0.12.24
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0 | 2017-11-14T18:58:09.511518Z | Download | 651a0eb08d5a771f25a1e243853ab1ec2886baf5c5a91bcc4a6871f9a1c6d5ed |
| 0.1.1 | 2017-11-30T23:23:05.178608Z | Download | 121501c814791e16613c33176da53469b572aeee8b78543e2164edd7bcc2ae8b |
| 0.2.0 | 2017-12-21T18:51:52.124230Z | Download | e9823b53a7481fea3cc5754f24944fd6ef6a8031497a87f449da538b25c24d73 |
| 0.2.1 | 2017-12-22T20:58:22.543423Z | Download | 01efb18e7bbb9687300cb35410d41946481c32a854d033adf6694075b4d0a4b9 |
| 0.2.2 | 2018-01-18T21:34:57.741980Z | Download | 79ce134a494d5339bd99c5e2f77f132fc51db42075c31bbfe870d56183232946 |
| 0.2.2+1 | 2018-01-18T22:13:55.627586Z | Download | b18a9d27c9b5784a74de48d11babbc2db79638aff94293eca7f1ef953d79314c |
| 0.2.3 | 2018-02-01T17:40:46.059803Z | Download | 4ac0a022b67888b9d1292510a1f4385e69c500166bfae8d2965bd971fbb6255c |
| 0.2.4 | 2018-03-01T20:44:29.955418Z | Download | 66c8c49bfc2561d5e07f31a010bc65bc5698e41dc7307e8b49d22a4b4cf127d6 |
| 0.2.5 | 2018-03-13T01:26:39.203867Z | Download | f5b99c182e8a2fe51d2bfe7376b52978f95f04f1f0a65e0a9f4cc77bcfd98714 |
| 0.2.6 | 2018-04-06T22:45:18.461363Z | Download | 1dc68dd68312a03a2c0ea644275a0223872fc21515eba7c6b92b40eb0a42dde1 |
| 0.2.6+1 | 2018-04-06T23:36:58.745934Z | Download | 6794050f1d3dead34491d9eaa818171adecbb8e7a98076bc63ccebe404e34822 |
| 0.2.6+2 | 2018-05-16T20:32:05.406801Z | Download | 4c1a0a3914f5c8a223c2b9ce67feeef3cc5c9e690ff9141473a87ef45fa808ae |
| 0.3.0 | 2018-06-05T15:22:00.494145Z | Download | 1dc91de2c16188d4c351cfac66ce67574831ed3c40a80864ce7f8ba1ca55bbe0 |
| 0.3.1 | 2018-06-22T19:36:57.232979Z | Download | 9da2ccef16566de864e3a1fea4adc274d726105d32e34a749a318d21704f558a |
| 0.3.1+1 | 2018-07-16T21:29:17.312833Z | Download | 4ff4bbacbd27e84d22664750dce25f68c49df7c52b649f4313a0ba6ba1576084 |
| 0.3.1+2 | 2018-07-24T23:39:29.800484Z | Download | b9627573d3fc4a00bf02f54c4f69be307c95c75b4fe49105eb0600cb328273bb |
| 0.3.1+3 | 2018-09-25T21:25:41.145120Z | Download | ef70cfa1e0de6bfc67e3351245a898cb831ea0b262f475399d7f9bef78fba58e |
| 0.3.1+4 | 2018-10-23T21:39:40.060660Z | Download | 6d4bfa079ef937b9b847b705237637b62c21d48599c28fc69f4e466524122f6f |
| 0.3.2 | 2019-04-10T20:40:32.436709Z | Download | 298307053d426e1881846ddf2d2f5c98f9d9fe98e8c68bdaaebf828602e46062 |
| 0.4.0 | 2019-04-23T19:49:59.071696Z | Download | 9f3d3b1d6733faf8e27560703736e39834df0bef9224a06a7cf7a96b6e46f92c |
| 0.4.1 | 2019-07-03T18:25:04.286584Z | Download | c29913e2bc13b286ffa488447d559a41556cd56a6c006623a22e59049a94a4c1 |
| 0.4.1+1 | 2019-08-08T16:22:05.288300Z | Download | 48706f0f42ce64df2f980d50404184463e019c36b0dcd09e68bfb7546c789ee4 |
| 0.4.2 | 2020-02-05T17:40:08.984587Z | Download | ed3082b3c5512ba6bbffe1f6b1ba165316607b7e6322a8cc37ee60964b8f2e06 |
| 0.4.3 | 2020-11-18T16:54:20.298276Z | Download | 20acd988503d0499ada4a85208a970c7ece0c7e56cd5ff1028052d396148290a |
| 0.4.4 | 2020-12-02T20:41:42.169228Z | Download | 418225797ea30b93c0301d8911446c0be4e3c6e3b0e721225050fe5ba92c4175 |
| 0.4.5 | 2020-12-08T22:25:46.657475Z | Download | 9e5aa739e28154fc8b5c483ab54ad861759529ec455f8636106166ad0e5ab1b8 |
| 0.4.6 | 2021-02-17T15:02:46.840875Z | Download | edd0f55c5af49a408311330cc84b213acc7491a85d6f2f890e503ffe00290176 |
| 0.4.7 | 2021-03-12T21:33:19.749211Z | Download | 9160104f468c8117f7dddd3c94d8f440d0f82a324bf29eb84e0b434cff7a0e03 |
| 1.0.0 | 2021-04-20T19:39:23.457714Z | Download | ad77deb6e9c143a3f550fbb4c5c1e0c6aadabe24274898d06b9526c61b9cf4fb |
| 1.1.0 | 2022-07-12T17:24:47.930736Z | Download | 5b7355c14258f5e7df24bad1566f7b991de3e54aeacfb94e1a65e5233d9739c1 |
| 1.1.1 | 2022-10-18T16:51:38.635204Z | Download | bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 |
| 1.1.2 | 2024-12-16T21:47:45.621647Z | Download | 4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33 |
| 1.2.0 | 2025-08-15T11:33:38.317684Z | Download | 4f64382b97504dc2fcdf487d5aae33418e08b4703fc21249e4db6d804a4d0187 |
| 1.3.0 | 2026-02-25T20:01:16.505138Z | Download | 4070d2a59f8eec34c97c86ceb44403834899075f66e8a9d59706f8e7834f6f71 |
| 1.3.1 | 2026-07-08T10:23:30.894436Z | Download | f2c223156a26eea323e6244b85141d76413a80aeee9fe0b380773789fabaf8ae |
| 1.3.2 | 2026-07-27T10:57:26.508684Z | Download | 94eaf6708fe64408c632ef2689ca3777b112f9421306ccf4f8c84d7c5c9f83f8 |
| 1.3.3 | 2026-09-02T12:25:57.100188Z | Download | d466ed2dc9c6cd1d169948879b84ee061eb5e22c64a7c6089879c6296d272a8d |
| 1.4.0 | 2026-10-14T09:37:40.524794Z | Download | 4703a785fbc3c266c5c7518589d0863f6a05078ee33f7ca5aa4b87a56f1cedd2 |
Dependencies
build "\u003e=0.11.2 \u003c0.13.0"
meta "^1.1.0"
path "^1.4.0"
yaml "^2.1.11"