Skip to content

feat: Support multi-module Java projects in tasks#244

Open
drmaniac wants to merge 1 commit intozed-extensions:mainfrom
drmaniac:multi-module-support
Open

feat: Support multi-module Java projects in tasks#244
drmaniac wants to merge 1 commit intozed-extensions:mainfrom
drmaniac:multi-module-support

Conversation

@drmaniac
Copy link
Copy Markdown

@drmaniac drmaniac commented May 8, 2026

Previously, Zed's Java tasks for running and testing applications did not correctly support multi-module Maven or Gradle projects. When executing a task from a file within a submodule, the commands would attempt to run at the root level, potentially leading to incorrect execution or failures.

This change introduces logic to dynamically determine the nearest Maven pom.xml or Gradle build.gradle/settings.gradle file relative to the currently active file. It then modifies the Maven and Gradle commands to target the specific module.

For Maven, this involves adding the -pl <module> and -am flags. For Gradle, it prepends the module path (e.g., :module-name:) to the run or test command. This ensures that tasks are executed within the context of the correct module, improving the developer experience for multi-module Java projects.

@cla-bot cla-bot Bot added the cla-signed label May 8, 2026
@tartarughina
Copy link
Copy Markdown
Collaborator

tartarughina commented May 8, 2026

Thanks for the PR, could you provide steps to test these changes or add how you tested them?

@drmaniac drmaniac force-pushed the multi-module-support branch from 5b53433 to 0e45c2c Compare May 8, 2026 20:57
Previously, Zed's Java tasks for running and testing applications
did not correctly support multi-module Maven or Gradle projects.
When executing a task from a file within a submodule, the commands
would attempt to run at the root level, potentially leading to
incorrect execution or failures.

This change introduces logic to dynamically determine the nearest
Maven `pom.xml` or Gradle `build.gradle`/`settings.gradle` file
relative to the currently active file. It then modifies the Maven
and Gradle commands to target the specific module.

For Maven, this involves adding the `-pl <module>` and `-am` flags.
For Gradle, it prepends the module path (e.g., `:module-name:`) to
the `run` or `test` command. This ensures that tasks are executed
within the context of the correct module, improving the developer
experience for multi-module Java projects.
@drmaniac drmaniac force-pushed the multi-module-support branch from 0e45c2c to bb03226 Compare May 8, 2026 21:06
@drmaniac
Copy link
Copy Markdown
Author

drmaniac commented May 8, 2026

Hi, I have added integration tests to this project (I wasn't sure if these are allowed/expected for extensions).

In addition, I apologize that the original PR had an issue with the Maven part; I have fixed it.

I also tested the changes in tasks.json by adding them as custom tasks in my local Zed config. I tried it out on a complex Gradle project with composite and multiple modules, and a Maven project with multiple modules.

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.

2 participants