Group targets by name
I'm using mage in a monorepo project with a small set of core targets (e.g., test, build, package, deploy, etc.) that are consistent across all "sub-projects" in the monorepo. Each sub-project has its own magefile.go and there is a root-level magefile.go that "aggregates" the targets of the sub-projects' magefile.go files with some namespacing. (I say "aggregates" because currently the aggregation is hand-curated.)
My project layout looks like...
my-project/
sub-project-A/
magefile.go
sub-project-B/
magefile.go
sub-project-C/
magefile.go
magefile.go
Each sub-project's targets are essentially...
$ mage -l
Targets:
test Runs unit tests.
build Compiles the project.
package Packages the project.
deploy Deploys the project.
And the (hand-curated) root-level targets are of the form...
$ mage -l
Targets:
test:all Runs all projects' unit tests.
test:a Runs project A unit tests.
test:b Runs project B unit tests.
test:c Runs project C unit tests.
build:all Compiles all projects.
build:a Compiles the A project.
build:b Compiles the B project.
build:c Compiles the C project.
It would be super helpful if mage's target import mechanism could do this all on a user's behalf by aggregating imported targets of the same name under a namespace (for example).
Originally posted by @jonasrmichel in https://github.com/magefile/mage/issues/108#issuecomment-425213249