Skip to content

Migrate Java code to Gradle #3833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 26, 2025
Merged

Migrate Java code to Gradle #3833

merged 21 commits into from
Jun 26, 2025

Conversation

Gaming32
Copy link
Collaborator

Java code in Theseus has historically been compiled using javac manually on the command-line, which is tedious and error-prone. This PR moves it to being compiled with Gradle.

@Gaming32 Gaming32 changed the base branch from main to josiah/mc-system-properties June 23, 2025 19:38
@Gaming32 Gaming32 marked this pull request as ready for review June 23, 2025 19:58
@Gaming32 Gaming32 added app Relates to Modrinth App DevEx Improvements to developer experience labels Jun 23, 2025
Copy link
Member

@AlexTMjugador AlexTMjugador left a comment

Choose a reason for hiding this comment

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

I agree that it's great to have a documented, automated, and reproducible way to build these helper Java scripts. That said, I find Gradle a bit too feature and boilerplate heavy for such simple single-file, no dependency scripts, especially when they are very likely to remain that way.

Have you considered using alternatives like Makefiles, xtasks, plain npm scripts, Task, Just, classic shell scripts, or something else along those simpler lines instead?

Gaming32 added 3 commits June 25, 2025 12:20
# Conflicts:
#	apps/app/tauri.conf.json
#	packages/app-lib/src/launcher/mod.rs
#	packages/app-lib/src/util/io.rs
#	packages/app-lib/src/util/jre.rs
Base automatically changed from josiah/mc-system-properties to main June 26, 2025 13:32
Copy link
Member

@AlexTMjugador AlexTMjugador left a comment

Choose a reason for hiding this comment

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

LGTM, we have discussed the appropriateness of using Gradle given our future plans over Slack. But conflicts need to be resolved before merging. As I think I've stated before, I recommend using rebasing for merge trains like this instead.

};

(env $dir_env_name:literal / $file_name:literal) => {
get_resource_file!(directory: env!($dir_env_name), file: $file_name)
Copy link
Member

@AlexTMjugador AlexTMjugador Jun 26, 2025

Choose a reason for hiding this comment

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

The compile error that happens here is quite tricky, because you indeed define the JAVA_JARS_DIR environment variable correctly in the build script. After some fiddling, I realized that if I moved its instruction before Gradle is executed it works fine. I'm not sure why exactly that helps, as the Rust compiler has to wait until the build script completes to build the actual crate anyway, so no race condition should be happening here... Probably.

@Gaming32 Gaming32 enabled auto-merge June 26, 2025 13:52
# Conflicts:
#	packages/app-lib/java/src/main/java/com/modrinth/theseus/JavaInfo.java
#	packages/app-lib/java/src/main/java/com/modrinth/theseus/MinecraftLaunch.class
#	packages/app-lib/java/src/main/java/com/modrinth/theseus/MinecraftLaunch.java
#	packages/app-lib/src/launcher/mod.rs
#	packages/app-lib/src/util/io.rs
#	packages/app-lib/src/util/jre.rs
@Gaming32 Gaming32 added this pull request to the merge queue Jun 26, 2025
Merged via the queue into main with commit 47af459 Jun 26, 2025
4 checks passed
@Gaming32 Gaming32 deleted the josiah/java-code-gradle branch June 26, 2025 16:10
AlexTMjugador added a commit that referenced this pull request Jun 26, 2025
An unforeseen consequence of PR #3833 landing was that `tauri dev`
stopped working reliably, getting softlocked when the `app-lib` crate
build script actually needed to build Java scripts: Gradle always
modifies a few files under the `.gradle` directory when run, which get
picked up by Tauri as source code changes that should trigger a rebuild,
but such rebuild triggers Gradle to run and modify those files again ad
infinitum.

This change fixes that by adding such a directory to a documented Tauri
exclusion file, restoring such functionality back.
github-merge-queue bot pushed a commit that referenced this pull request Jun 26, 2025
…ked (#3847)

An unforeseen consequence of PR #3833 landing was that `tauri dev`
stopped working reliably, getting softlocked when the `app-lib` crate
build script actually needed to build Java scripts: Gradle always
modifies a few files under the `.gradle` directory when run, which get
picked up by Tauri as source code changes that should trigger a rebuild,
but such rebuild triggers Gradle to run and modify those files again ad
infinitum.

This change fixes that by adding such a directory to a documented Tauri
exclusion file, restoring such functionality back.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Relates to Modrinth App DevEx Improvements to developer experience
Development

Successfully merging this pull request may close these issues.

2 participants