build_semver 1.0.0 build_semver: ^1.0.0 copied to clipboard
A builder for extracting a package version into code.
Include the version of your package in our source code.
-
Add
build_semver
topubspec.yaml
. Also make sure there is aversion
field.name: my_pkg version: 1.2.3 dependencies: pub_semver: ^2.1.4 dev_dependencies: build_runner: ^1.0.0 build_semver: ^2.0.0
-
Run a build.
> dart pub run build_runner build
lib/src/version.dart
will be generated with content:// Generated code. Do not modify. import 'package:pub_semver/pub_semver.dart'; final packageVersion = Version.parse('1.2.3');
To change the path of the generated file, create a
build.yaml
in the root of your
package. By changing the output
option of this builder, the path can be
customized:
targets:
$default:
builders:
build_semver:
options:
output: lib/src/custom/path/to/version.dart