-
-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for excluding targets from wildcard selection #1550
Comments
-
to exclude targets from wildcard selection-
to exclude targets from wildcard selection (RFC)
Sounds like a great idea. Seems like we're gradually growing our own version of the Bazel Query syntax 😛 https://docs.bazel.build/versions/main/query-how-to.html |
A small update. I started to experiment with it more than once, but this one isn't as easy as the |
-
to exclude targets from wildcard selection (RFC)This PR add support for new selector pattern `_:Type`. In addition to `_` and `__`, which select arbitrary segments, the `_:MyType` and `__:MyType` patterns can select modules of the specified type. The type is matched by it's name and optionally by it's enclosing types and packages, separated by a `.` sign. Since this is also used to separate target path segments, a type selector segment containing a `.` needs to be enclosed in parenthesis. A full qualified type can be enforced with the `_root_` package. Example: Find all test jars ```sh > mill resolve __:TestModule.jar > mill resolve "(__:scalalib.TestModule).jar" > mill resolve "(__:mill.scalalib.TestModule).jar" > mill resolve "(__:_root_.mill.scalalib.TestModule).jar" ``` If a `^` or `!` is preceding the type pattern, it only matches segments not an instance of that specified type. Please note that in some shells like `bash`, you need to mask the `!` character. Example: Find all jars not in test modules ```sh > mill resolve __:^TestModule.jar ``` You can also provide more than one type pattern, separated with `:`. Example: Find all `JavaModule`s which are not `ScalaModule`s or `TestModule`s: ```sh > mill resolve "__:JavaModule:^ScalaModule:^TestModule.jar" ``` Remarks: * Kudos to @lihaoyi who refactored the resolver in #2511 and made this PR possible. I tried to implement it multiple times before, and ever got bitten by the old gnarly resolver code. * It's currently not possible to match task/target types. It might be possible, but due to `Task` being a parametrized type, it might not be as easy to implement and use. Fix #1550 Pull request: #2997
Selecting many targets with wildcard and the braces syntax is very convenient, but if there is need to exclude some targets from the expansion, one needs to enumerate all targets separately (or find clever smaller selection pattern).
As a dual of
+
to select multiple targets (e.g.mill foo.compile + bar.compile
) it would be convenient if we could also support a-
to de-select some targets, e.g. to match all compile targets, but notbar.compile
we could then write:mill __.compile - bar.compile
.The text was updated successfully, but these errors were encountered: