Skip to content

Build: Update to EGT 0.7, KGP 2.3, Gradle 9, UC 453#174

Open
RedEpicness wants to merge 6 commits intomasterfrom
feature/gradle-9
Open

Build: Update to EGT 0.7, KGP 2.3, Gradle 9, UC 453#174
RedEpicness wants to merge 6 commits intomasterfrom
feature/gradle-9

Conversation

@RedEpicness
Copy link
Contributor

@RedEpicness RedEpicness commented Mar 9, 2026

I need this as a prerequisite for a change in UniversalCraft.

While most of the update is self-explanatory, the changes to the now deprecated -Xjvm-default compiler options caused a lot of unnecessary changes to the API, alongside build errors since @JvmDefaultWithoutCompatibility in state.kt requires the option to be enabled. Thus, I decided to migrate over to the new -jvm-default option.

Attempting to migrate according to the migration guidelines does not immediately fix the issue.

The change from all to no-compatibility in layoutdsl/build.gradle.kts and statev2/build.gradle.kts was smooth and only required the removal of @JvmDefaultWithoutCompatibility in state.kt

But, the change from all-compatibility to enable in build.gradle.kts did not remove the unnecessary api changes. I wasn't able to manually remove them with annotations so i gave up and after a lot of trial and error I ended up with migrating to no-compatibility like the other two modules, which removed a much much smaller list of the generated compatibility functions which I re-added with @JvmDefaultWithCompatibility annotations where needed. There was one api removal that I couldn't avoid, but to my knowledge it was not necessary and should be ok to remove. I left a separate comment on the PR about this.

If anyone has any idea on how to tackle this by keeping the option set to enabled, let me know.

This also requires increasing the minimum required Kotlin version to 1.9, because targeting 1.6 is no longer supported by Kotlin Gradle Plugin 2.3. This also adopts modern "jvm-default" compiler option and changes corresponding annotations accordingly to minimise binary changes.
public final class gg/essential/elementa/UIComponent$sam$i$java_util_function_Predicate$0 : java/util/function/Predicate {
public fun <init> (Lkotlin/jvm/functions/Function1;)V
public final synthetic fun test (Ljava/lang/Object;)Z
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a side effect of changing how the jvm-default option behaves. Given that it's a generated class I cannot add an annotation to ensure the generation of this, but looking at both the class itself and it's compiled version, it seems like the only use of this class is internal and not applicable or useful to any external user of the UIComponent class. Unless another solution is found for the handling of jvm-default, I want someone else to verify this removal is ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is a side effect of anything to do with jvm-default. It didn't happen in the other PR.

It definitely looks like an internal class though, that probably shouldn't have been public to begin with.
I reckon it's either the bump to the Kotlin compiler which made it private, or the bump to binary-compatibility-validator which now excludes such internal (but technically public) classes.

Do you know which lambda in the source code this class corresponds to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking into the decompiled UIComponent , the only use of the Predicate class is in the removeEffect() function (the no-args one). This was the basis of my assumption that it's only ever meant to be used internally and thus is useless to expose. The same can be seen in the compiled class before the update so I assume it could be the compatibility validator ignoring this now. In either case I think it's safe to safe to remove.
CleanShot (Elementa – kotlinDecompiledUIComponent decompiled java) 2026-03-13 at 20 23 49

Copy link
Contributor

Choose a reason for hiding this comment

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

issue: It seems like this is the wrapper jar from Gradle 8.7-8.8.

Note that you first need to bump the Gradle version, and only then run the wrapper task (or run the wrapper task twice), otherwise you'll still be using the old Gradle version to generate the wrapper.

8
16
17
21
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: We can probably drop 16 and 17. Given we compile a single Elementa library for all MC versions, we only really need 8 for that (and 21 to run Gradle).

kotlinx-coroutines = "1.5.2"
jetbrains-annotations = "23.0.0"
universalcraft = "406"
universalcraft = "453"
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Do we need to bump UC for this?

compileOnly("org.lwjgl:lwjgl-opengl:3.3.1")
}
tasks.compileKotlin.setJvmDefault("all")
kotlin.compilerOptions.jvmDefault.set(JvmDefaultMode.NO_COMPATIBILITY)
Copy link
Contributor

@Johni0702 Johni0702 Mar 10, 2026

Choose a reason for hiding this comment

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

The change from all to no-compatibility in layoutdsl/build.gradle.kts and statev2/build.gradle.kts was smooth and only required the removal of @JvmDefaultWithoutCompatibility in state.kt

note: This isn't actually a change. The equivalent option to -Xjvm-default=all is -jvm-default=no-compatibility.

The usage of JvmDefaultWithoutCompatibility was incorrect to begin with, because -Xjvm-default=all doesn't generate the compatibility classes to begin with (that's what -Xjvm-default=all-compatibility is for).
This is because we import the code for the unstable/ projects from Essential (except for the build.gradle.kts files) and Essential's build.gradle.kts does use -Xjvm-default=all-compatibility.

I'll open a PR on Essential to rectify this, and once that's merged, import that change (and any other changes which haven't been imported yet) into Elementa's repo.
Edit: Done. The JvmDefaultWithoutCompatibility is gone now.

import java.awt.Color

@JvmDefaultWithCompatibility
interface ImageProvider {
Copy link
Contributor

Choose a reason for hiding this comment

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

note: I've pulled out this change of "generate compatibility classes by default" to "only for old interfaces" into a separate PR because it can be done independently of the EGT/KGP/Gradle bump, and so simplifies the changes in this PR.

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.

2 participants