mill icon indicating copy to clipboard operation
mill copied to clipboard

Differentiate between a compile JVM and a run JVM - add a `forkJvmId` and `forkJavaHome`?

Open lefou opened this issue 6 months ago • 2 comments

Currently, the JavaHomeModule.javaHome, which is derived from jvmId is used in different situations, but most often for compilation and running. I'd like to use a different JVM for running a module than was used for compiling a module, which is currently not possible.

To avoid repetition by adding a forkJvmId and forkJavaHome (and other intermediate internal task like forkJvmIndexVersion), the Mill-idiomatic way would be to have separate module references like compileJvm: ModuleRef[JavaHomeModule] and forkJvm: ModuleRef[JavaHomeModule].

On the other hand, this is almost what we had before https://github.com/com-lihaoyi/mill/pull/5327. So, I'd like to have a discussion, what a good compromise between clean setup and convenience could look like.

lefou avatar Jun 18 '25 20:06 lefou

Seems like instantiating a nested RunModule that depends on the parent but has different run configuration would be the most straightforward way right now?

lihaoyi avatar Jun 19 '25 05:06 lihaoyi

Sounds doable, except a bit tedious for the typical cases where I met this requirement: tests.

While test is already a nested RunModule, the runtime-JVM is still shared with the compiletime-JVM, so the resulting setup to run tests isn't only not intuitive, it's also open to be used wrong, as there is still a testForked task which is configured plain wrong.

lefou avatar Jun 19 '25 06:06 lefou