Skip to content

run plugin - #12

Merged
oliveryasuna merged 10 commits into
mainfrom
1-run-plugin
Sep 23, 2026
Merged

oliveryasuna merged 10 commits into
mainfrom
1-run-plugin

Conversation

@oliveryasuna

Copy link
Copy Markdown
Owner

No description provided.

@oliveryasuna oliveryasuna linked an issue Sep 7, 2026 that may be closed by this pull request
@oliveryasuna
oliveryasuna marked this pull request as ready for review September 9, 2026 12:29
@oliveryasuna
oliveryasuna marked this pull request as draft September 9, 2026 12:31
@oliveryasuna
oliveryasuna marked this pull request as ready for review September 9, 2026 12:45
* Prefer a JetBrains Runtime for enhanced class redefinition. Advisory
* only.
*/
public abstract val preferJetBrainsRuntime: Property<Boolean>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. And this makes the DSL cleaner if we ever want to support more runtimes.

@oliveryasuna oliveryasuna Sep 13, 2026 •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Keep as is.

  2. 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.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, if we choose option 2, we should update #9 to make sure we remember to include foojar-resolver-convention.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See HotswapSpec comment.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this as a follow-up.

val project = ctx.project
val loom = project.extensions.getByType(LoomGradleExtensionAPI::class.java)

project.afterEvaluate {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project.afterEvaluate is generally discouraged in Gradle.
Instead, a better approach is to use reactive or lazy configuration.
That is

  • Reactive: whenever a RunConfig is registered, it is finalized and applied to Loom.
  • Lazy: Loom run configs are configured with configureEach, pulling the corresponding ModKit run config.

@oliveryasuna oliveryasuna Sep 13, 2026 •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this as a follow-up.

@oliveryasuna
oliveryasuna merged commit 7587bbc into main Sep 23, 2026
3 checks passed
@oliveryasuna
oliveryasuna deleted the 1-run-plugin branch September 23, 2026 19:12
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.

run plugin

2 participants