GPM ("General Package Manager") is a programming tool designed for monorepos (multi-package
repositories). GPM automatically discovers packages and infers how to test/build them.
You can optionally write .gpm.yaml
configuration files.
- Custom test/build scripts (Bash, Dart, etc.).
- GPM saves time and is less error-prone.
- CI tools
- GPM is just a simple command-line tool that developers can use in their local development machine. It doesn't replace CI tools. GPM can be used to generate configurations for CI tools.
- mono_repo
- mono_repo appears to be focused on running Travis CI tests locally.
Then run:
pub global activate gpm
Alternatively, if you have only Flutter SDK installed, you can run:
flutter pub global activate gpm
Test installation by running gpm
. If you haven't configured your PATH environmental variable
properly (see Dart SDK / Flutter SDK instructions), attempting to run GPM will give you a "command
not found" error message. In this case, you can still use GPM by running pub global run gpm
(or
flutter pub global run gpm
).
gpm info
The command will show debug information.
gpm get
The above command will run:
flutter pub get
(for each Flutter SDK package)pub get
(for each Dart SDK package)
gpm get --link
The above command will do gpm get
and link all local packages together.
gpm test
The above command will run:
flutter test
(for each Flutter SDK package, whenflutter_test
dependency is found)flutter pub run test
(for each Flutter SDK package, whenflutter_test
dependency is not found)pub run test
(for each Dart SDK package)
gpm build
The above command will run:
flutter build apk
(for each Flutter SDK package that hasandroid
directory)flutter build ios
(for each Flutter SDK package that hasios
directory)flutter build web
(for each Flutter SDK package that hasweb
directory)pub global run webdev build
(for each Dart SDK package that hasweb
directory)- If
webdev
is not activated, it activates it.
- If
gpm ci init azure
This will generate ".ci/.azure-pipelines.yml".
gpm ci init github
This will generate ".github/workflows/dart.yml".
gpm ci init gitlab
This will generate ".gitlab-ci.yml".
gpm ci init travis
This will generate ".travis-ci.yml".
gpm upgrade
This is just a shorthand for pub global activate gpm
.
The following filenames are supported:
- .gpm.yaml
- gpm.yaml
By default, GPM assumes that every directory that contains pubspec.yaml is a package. Packages are currently handled in alphabetical order.
You can customize this in gpm.yaml
:
packages:
- path: some/package
# Override default test step(s)
test:
run: flutter test
# Override default build step(s)
build:
steps:
- run: flutter build apk
- run: flutter build ios
- run: flutter build web
- path: some/other/package
In gpm.yaml
:
scripts:
protos:
description: Generates Dart files from Protocol Buffers definitions.
steps:
# Define working directory
- directory: some/directory
# Run 'protoc' command.
# @(X) causes every "/" in X to be replaced with "\" when running in Windows.
run: protoc --dart-out @(lib/generated/) definition.proto
# You could optionally define platform:
# platform: "posix || windows"
# Another step
- directory: some/directory
run: protoc --dart-out @(lib/generated/) another_definition.proto
Then run:
gpm run protos
Syntax rules for run are:
"a b c"
(a quoted argument)"\@\(\)"
(escape character "\" works inside a quoted argument)$(ENV_VAR)
(an environmental variable)@(a/b/c)
(replaces "/" with "" in Windows)