-
Notifications
You must be signed in to change notification settings - Fork 289
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
Conversation
If the tauri feature is enabled, the resource will be loaded from Tauri resources. If the tauri feature is disabled, the resource will be extracted to a temp directory.
There was a problem hiding this 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 Makefile
s, xtask
s, plain npm
scripts, Task, Just, classic shell scripts, or something else along those simpler lines instead?
# 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
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
# 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
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.
…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.
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.