Skip to content
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

Backport "Consolidate jvm subprocess and inprocess functions (#4456)" to 0.12 #4504

Conversation

sake92
Copy link
Contributor

@sake92 sake92 commented Feb 7, 2025

Backport of #4456

sake92 and others added 4 commits February 7, 2025 14:15
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>
@lihaoyi lihaoyi marked this pull request as ready for review February 7, 2025 14:37
@lihaoyi lihaoyi merged commit 2b9aca7 into com-lihaoyi:0.12.x Feb 7, 2025
28 of 40 checks passed
@lefou lefou added this to the 0.12.8 milestone Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants