-
-
Notifications
You must be signed in to change notification settings - Fork 413
Consolidate jvm subprocess and inprocess functions #4456
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
Consolidate jvm subprocess and inprocess functions #4456
Conversation
…assLoader, runClassLoader}. Remove JavaModule.launcher
…github.com:sake92/mill into consolidate-jvm-subprocess-and-inprocess-functions
The naming is pulled a bit in two directions
TBH I'm not sure which one is better. @lefou @lolgab not sure if you guys have any opinions here? |
This is to let you select the parent classloader; at the minimum it lets you decide whether or not to include the current Mill classloader on the child classpath, or have the child classpath entirely isolated. So we probably need to keep it as necessary complexity in the API |
That's right. For now can just leave them in place |
Seems that |
Maybe we can try closing it all the time and see if any tests break? I don't understand why we wouldn't close it either haha |
The name |
…github.com:sake92/mill into consolidate-jvm-subprocess-and-inprocess-functions
Good point. |
…assLoader] (parent cl)
…github.com:sake92/mill into consolidate-jvm-subprocess-and-inprocess-functions
…github.com:sake92/mill into consolidate-jvm-subprocess-and-inprocess-functions
In the last commit I only changed a comment. |
Last few comments, after that we can merge it! Test failures are probably flakes and can be ignored. |
Should be good now. |
@sake92 looks like there's a compile error somewhere |
Thanks @sake92! Failures look unrelated so I'll merge this first and deal with failures asynchronously. Could you help open a PR backporting this to |
Changes: - added functions based on com-lihaoyi#3772 description - the process related ones now return os-lib process result or subprocess handle - `callClassLoader` uses a loan pattern function and closes the classloader after usage - added `mill.util.ProcessUtil.toResult(processResult)` to handle process result in same way https://github.com/com-lihaoyi/mill/blob/main/main/util/src/mill/util/Jvm.scala#L352-L357 Some minor questions/suggestions: 1. current `spawnClassloader` is more flexible, you can pass your own classloader rather that use `getClass.getClassLoader`, this is ok I guess? 1. suggestion to name `spawnClassLoader` as `createClassLoader` 1. suggestion to name `callClassloader` as `withClassloader` (common loan pattern name) 1. `getMainMethod` is not public so `runLocal` can't be removed.. so expose `getMainMethod` or leave `runLocal` as is? 1. Some calls are inside build.mill files. I have to wait for new version of Mill with these changes included, and then update them? 1. Not sure if `closeClassLoaderWhenDone` is needed, I don't understand why it is left unclosed in few places. Closes com-lihaoyi#3772 --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
ref: com-lihaoyi/mill@f35464c com-lihaoyi/mill#4456 Signed-off-by: unlsycn <unlsycn@unlsycn.com>
ref: com-lihaoyi/mill@f35464c com-lihaoyi/mill#4456 Signed-off-by: unlsycn <unlsycn@unlsycn.com>
ref: com-lihaoyi/mill@f35464c com-lihaoyi/mill#4456 Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Fixes #4863 Seems like it was broken by #4837 which replaced `Jvm.runSubprocess` with `os.call`, which unfortunately had different stream forwarding defaults. This class of problem should be impossible in future thanks to #4456 from @sake92 which standardizing the stream forwarding defaults of `Jvm.*Process` APIs with `os.*`
Changes:
Jvm.*
subprocess/inprocess APIs (500USD Bounty) #3772 descriptioncallClassLoader
uses a loan pattern function and closes the classloader after usagemill.util.ProcessUtil.toResult(processResult)
to handle process result in same way https://github.com/com-lihaoyi/mill/blob/main/main/util/src/mill/util/Jvm.scala#L352-L357Some minor questions/suggestions:
spawnClassloader
is more flexible, you can pass your own classloader rather that usegetClass.getClassLoader
, this is ok I guess?spawnClassLoader
ascreateClassLoader
callClassloader
aswithClassloader
(common loan pattern name)getMainMethod
is not public sorunLocal
can't be removed.. so exposegetMainMethod
or leaverunLocal
as is?I have to wait for new version of Mill with these changes included, and then update them?
closeClassLoaderWhenDone
is needed, I don't understand why it is left unclosed in few places.Closes #3772