Skip to content

Rustify tasks#274

Open
drmaniac wants to merge 5 commits into
zed-extensions:mainfrom
drmaniac:rustify-tasks
Open

Rustify tasks#274
drmaniac wants to merge 5 commits into
zed-extensions:mainfrom
drmaniac:rustify-tasks

Conversation

@drmaniac

Copy link
Copy Markdown
Contributor

Key Highlights of the PR Description:

  • Related Issue: Connected to Issue Replace shell-based task commands with Rust proxy subcommands #252
  • Divergence from Proposal:
    • New Crate vs. Subcommand: Introduced a separate workspace binary crate java-task-helper under Cargo.toml rather than adding a subcommand to the LSP proxy, keeping the LSP proxy focused.
    • Direct Execution: The helper runs the resolved task directly ( Command::execute in command.rs) rather than outputting JSON to stdout for downstream execution.
    • Native Cache Clean: Clears the JDTLS cache directly in Rust ( std::fs::remove_dir_all in main.rs) instead of delegating to shell utilities like find and rm (Job itself is now OS independent).

drmaniac added 2 commits June 17, 2026 08:06
- Implement a new `java-task-helper` binary to handle build tool commands
- Add support for Maven and Gradle build tool detection and execution
- Integrate `java-task-helper` into the Zed Java extension tasks
- Add automated download logic for the task helper binary
- Update `justfile` with new recipes for building and installing the helper
- Update `Cargo.lock` and `Cargo.toml` with new dependencies
- add test class, run all tests, and clear cache tasks to tasks.json
- refactor binary download logic by moving it from proxy.rs to download.rs
- update download logic to use allow_download flag and handle status updates
- implement remove_all_files_except in the download flow
@cla-bot cla-bot Bot added the cla-signed label Jun 17, 2026
- update run_test_method to use file argument for module lookup
- update run_test_class to use file argument for module lookup
- update run_all_tests to use file argument for module lookup
- refactor task_clear_cache to execute directly instead of returning TaskCommand
- update main entry point to handle clear-cache subcommand
@drmaniac drmaniac force-pushed the rustify-tasks branch 3 times, most recently from 06b2fed to c192e2a Compare June 17, 2026 11:52
- update release-proxy.yml to build and package java-task-helper
- update task_verification_test.rs to dynamically locate java-task-helper binary
- remove hardcoded paths for task helper in tests

@playdohface playdohface left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I like this, it works on my machine™️ and already gave me ideas on how to make the tasks smarter and gives us a sane programming model for doing so.
Also, all that is missing to make this work ootb in Windows is a platform-independent way of figuring out the extension workdir in the tasks.json context - either via upstream changes in Zed or with some clever polyglot scripts.

Caveat: I can't speak to the changes in the github-workflows, it looks fine but I know too little about github workflows to say with confidence

fn run_all_tests(&self, file: &str) -> TaskCommand;
}

pub fn detect_build_tool(cwd: &Path) -> (Box<dyn BuildTool>, PathBuf) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this could be smarter, with similar logic like in find_closest_module - we should determine the correct build-tool and wrapper per file, walking up the tree until we find pom.xml or build.gradle and consider that the "project root". Currently, as was the case with the old shell script, the builtin tasks break if you don't open your project at the java project root which can be quite annoying

Comment thread src/task.rs
};

const TASK_HELPER_BINARY: &str = "java-task-helper";
const TASK_HELPER_INSTALL_PATH: &str = "proxy-bin";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: probably proxy-bin/ is not a great name for this folder anymore now that it contains more than just the proxy binary. I vote bin/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1 on bin/

@drmaniac

Copy link
Copy Markdown
Contributor Author

I like this, it works on my machine™️ and already gave me ideas on how to make the tasks smarter and gives us a sane programming model for doing so. Also, all that is missing to make this work ootb in Windows is a platform-independent way of figuring out the extension workdir in the tasks.json context - either via upstream changes in Zed or with some clever polyglot scripts.

Caveat: I can't speak to the changes in the github-workflows, it looks fine but I know too little about github workflows to say with confidence

Hi thanks,
Thanks especially for the polyglot keyword.
I won't get to my Windows machine until tonight. But I think this could work. I will try it out then and adjust it if necessary.

Example tasks.json:

  {
    "label": "Test class $ZED_CUSTOM_java_class_name",
    "command": ":<<\"::WINDOWS_BATCH\"\n@echo off\nset \"EXT=%LOCALAPPDATA%\\zed\\extensions\\work\\java\"\ncall \"%EXT%\\proxy-bin\\java-task-helper\" run-test-class \"%ZED_FILE%\" \"%ZED_CUSTOM_java_package_name%\" \"%ZED_CUSTOM_java_class_name%\" \"%ZED_CUSTOM_java_outer_class_name%\"\ngoto :EOF\n::WINDOWS_BATCH\nEXT=\"${XDG_DATA_HOME:-$HOME/.local/share}/zed/extensions/work/java\"; [ \"$(uname 2>/dev/null)\" = \"Darwin\" ] && EXT=\"$HOME/Library/Application Support/Zed/extensions/work/java\"; [ -n \"$LOCALAPPDATA\" ] && EXT=\"$(cygpath -u \"$LOCALAPPDATA\" 2>/dev/null || echo \"$LOCALAPPDATA\")/zed/extensions/work/java\"; \"$EXT/proxy-bin/java-task-helper\" run-test-class \"$ZED_FILE\" \"$ZED_CUSTOM_java_package_name\" \"$ZED_CUSTOM_java_class_name\" \"${ZED_CUSTOM_java_outer_class_name:-}\"",
    "use_new_terminal": false,
    "reveal": "always",
    "tags": ["java-test-class", "java-test-class-nested"]
  }

@playdohface

Copy link
Copy Markdown
Collaborator

@drmaniac yes, if we can truly make this work across platforms and shells that's a major win imo
Just some more things to keep in mind:

@tartarughina

Copy link
Copy Markdown
Collaborator

Could we maybe inject the PATH to task-helper from Zed somehow? That would simplify the code in tasks.json and rely on the extension initialization accounting for all sort of install types

@playdohface

playdohface commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

@tartarughina Zed would have to provide this as a TaskVariable. It might be easier to convince the Zed team to just provide the extension-workdir or its parent as a TaskVariable to all tasks instead of doing something along the lines of zed-industries/zed#45932 and that would effectively solve our problem here, so I think it's worth a shot

That's what I believe would be required on the Zed side: zed-industries/zed#59564
It's still somewhat awkward because we'd need to append to the path in an OS and shell-agnostic way but it would be better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants