-
-
Notifications
You must be signed in to change notification settings - Fork 347
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 type selectors in Resolve #2997
Conversation
_:Type
pattern in Resolve_:Type
and __.Type
patterns in Resolve
_:Type
and __.Type
patterns in Resolve
I think this looks great. The syntax I think is worth discussing. How about a syntax like this? > mill resolve __:TestModule.jar
> mill resolve __:scalalib.TestModule#jar
> mill resolve __:mill.scalalib.TestModule#jar
> mill resolve __:_root_.mill.scalalib.TestModule#jar Or in general > mill resolve my.initial.selector:pkg.and.name.of.ModuleTrait#path.to.target From my experiments, this seems to not need escaping on sh/bash/zsh, both in scripts and in the CLI. ( We could also just say that we require quoting for using this syntax, like we do for the cross-build |
I agree I'd also avoid a dedicated end-marker, especially, as I think this feature is used with simple class names most of the time. And making it optional has a higher change for misuse than the So, I'd either like to find a better separator or require the use of parenthesis in case a separator is needed, in which case we could simple use the dot (
This might come with it's own issue in some shells, when used unquoted. > mill resolve __:TestModule.jar
> mill resolve __:(scalalib.TestModule).jar
> mill resolve __:TestModule.jar # no separator needed
> mill resolve __:scalalib$TestModule.jar # current approach, clashes with variable substitution
> mill resolve __:scalalib#TestModule.jar # might be interpreted as comment
> mill resolve __:scalalib%TestModule.jar # might look like a vairable on Windows
> mill resolve __:scalalib§TestModule.jar # pretty uncommon, but as near on the keyboard as the others
> mill resolve __:scalalib+TestModule.jar # semantically off, but should have no side-effects |
I know, that providing multiple options might increase the complexity, but how about supporting both, The implementation of the type matcher is already supporting > mill resolve __:TestModule.jar
> mill resolve __:scalalib$TestModule.jar
bash> mill resolve __:scalalib\$TestModule.jar
> mill resolve __:(scalalib.TestModule).jar
bash> mill resolve __:\(scalalib.TestModule\).jar
bash> mill resolve "__:(scalalib.TestModule).jar" |
The nice thing is, since each module is an valid Scala object, it has a unique type on it's own, so we can easily exclude specific modules from wildcards. bash> mill __:\(\!integration.slow\).testCached
bash> mill __:\!integration\$slow.testCached Runs all |
(1) I think we definitely should use (2) Looking at your examples, I think we 100% need to suggest people use quotes. Given constraint (1) above, there simply aren't any intuitive symbols we can use to separate the type selector from the task selector, and using backslashes everywhere to escape things quickly turns to symbol soup that is impossible to skim (3) Given (1) and (2), If we're going to be quoting things, then we might as well make it look like "normal" syntax. So something like this might make the most sense:
This would at least be familiar(ish) to people who are used to Scala, where |
I agree with the In fact, I borrowed the There is one ugly fact with quoting the bash> mill resolve "__:(_root_.mill.scalalib.TestModule):(!my.test).test"
bash: !my.test: event not found
bash> mill resolve "__:(_root_.mill.scalalib.TestModule):(\!my.test).test"
[1/1] resolve
1 targets failed
resolve Parsing exception Position 1:37, found ":(\\!my.te"
bash> mill resolve "__:(_root_.mill.scalalib.TestModule):(\\!my.test).test"
[1/1] resolve
1 targets failed
resolve Parsing exception Position 1:37, found ":(\\!my.te" We could support some alternative though, like the So, my takeaway is, you would rather like the wildcard inside the parenthesis like |
@lihaoyi I changed the parenthesis handling and added the |
I think it looks great. I think we might not want to support bash-3.2$ echo "hello!world"
bash: !world": event not found
bash-3.2$ echo 'hello!world'
hello!world I think as a general rule for the CLI, we probably want to use syntax that works the same when quoted in either single or double quotes. Otherwise you start having to worry about using the right set of |
Let's promote the |
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
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 likebash
, you need to mask the!
character.Example: Find all jars not in test modules
> mill resolve __:^TestModule.jar
You can also provide more than one type pattern, separated with
:
.Example: Find all
JavaModule
s which are notScalaModule
s orTestModule
s:Remarks:
Task
being a parametrized type, it might not be as easy to implement and use.Fix #1550
Pull request: #2997