Repository navigation
run plugin - #12
run plugin#12
Conversation
160c910 to
347a7ef
Compare
| * Prefer a JetBrains Runtime for enhanced class redefinition. Advisory | ||
| * only. | ||
| */ | ||
| public abstract val preferJetBrainsRuntime: Property<Boolean> |
There was a problem hiding this comment.
I think it would be better to split this into a three-state enum with:
DISABLED: don't check the JVM.WARNING: print a message if JBJRE is not used, explaining why it may be needed, and link to a guide.REQUIRED: attempt to set up JBJRE via foojay resolver and set the respective VM args; otherwise throw an error.
Generally, an option that just prints a warning by default without telling 'why' and 'what to do' is just confusing for users.
There was a problem hiding this comment.
I agree. And this makes the DSL cleaner if we ever want to support more runtimes.
There was a problem hiding this comment.
I tried this and encountered an issue with one part: The run plugin can't set up foojay itself. foojar-resolver-convention is a settings plugin (it lives in the consumer's settings.gradle.kts). The run is a project plugin.
And I think we should keep that pattern strict for all plugins except maybe multiversion, since it wraps Stonecutter, we may want to add some convenience options to configure Stonecutter without stonecutter.gradle.kts. But I digress (and ultimately that'll depend a lot on you, since you know Stonecutter best, of course)...
Since the run plugin is a project plugin, it can't inject a toolchain resolve into the consumer's settings. What it can do is request a JETBRAINS toolchain and rely on the consumer having a resolver + auto-download enabled.
Two options I can think of:
-
Keep as is.
-
Add the enum, but instead of ever throwing, make it a best-effort:
enum class HotswapMode {
OFF, // don't probe
WARN, // default: probe, and if not JBR/DCEVM, explain why + link a guide
ENFORCE // best-effort for GRADLE-launched runs only
}(I definitely think we should keep the default to WARN. I'd love to see more mod developers use hotswapping).
Gradle itself detects JETBRAINS (JvmVendorSpec.JETBRAINS), so that part is really easy. But remember that most mod developers use IntelliJ. IDE-launched runs use the IDE's run-config JVM, not the Gradle toolchain. So, pointing the Gradle run task at a JBR does nothing for them.
What do you think? Should we keep as is, or make it a best-effort (no hard throw)? I'm leaning the latter.
There was a problem hiding this comment.
Note, if we choose option 2, we should update #9 to make sure we remember to include foojar-resolver-convention.
There was a problem hiding this comment.
Let's put this as a follow-up.
| * | ||
| * Pure, so it can be tested without launching a given JVM. | ||
| */ | ||
| internal fun hotswapReport(vendor: String, vmName: String, preferJetBrainsRuntime: Boolean): String { |
There was a problem hiding this comment.
Let's put this as a follow-up.
| val project = ctx.project | ||
| val loom = project.extensions.getByType(LoomGradleExtensionAPI::class.java) | ||
|
|
||
| project.afterEvaluate { |
There was a problem hiding this comment.
project.afterEvaluate is generally discouraged in Gradle.
Instead, a better approach is to use reactive or lazy configuration.
That is
- Reactive: whenever a
RunConfigis registered, it is finalized and applied to Loom. - Lazy: Loom run configs are configured with
configureEach, pulling the corresponding ModKit run config.
There was a problem hiding this comment.
I get your point, and I agree something needs to change here, but I don't think either proposed approach solves the problem. The problem to solve (which afterEvaluate currently solves in its own way) is making a structural decision from a resolved Property value. In other words, "does this run exist at all?", "which variant runs exist?", "what dependencies go in the staging Configuration?". Those need the user's final value *at configuration time, and that is what actually forced afterEvaluate here. No provider can express "don't create this run."
However, I absolutely agree something needs to change here. Specifically, the "lazy" part. Loom exposes runDirectory/jvmArguments/programArguments as lazy properties, so it must be possible to drop snapshot()/.get() entirely.
This will take some time to think about, so I vote we keep as is for now, and document this as a potential "re-address before v1".
Thoughts?
There was a problem hiding this comment.
Let's put this as a follow-up.
4a3e65d to
9062358
Compare
No description provided.