Skip to content

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
lihaoyi added a commit that referenced this pull request Feb 16, 2025
Should fix the rebootstrap problems found in
#4545 and
#4570 that seems to be caused by
a mistake in this backport
#4504. Not sure why this causes
a hang, but for now just fixing it to revert to the previous semantics

Tested manually via

```bash
./mill dist.installLocal
git checkout main
./mill-assembly.jar 'integration.invalidation[selective-execution].local.fork.test' mill.integration.SelectiveExecutionWatchTests.watch.changed-code
```

Doing this manually on `0.12.x` hangs, whereas doing it on this PR
succeeds
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