microsoft / vscode-gradle

Manage Gradle Projects, run Gradle tasks and provide better Gradle file authoring experience in VS Code
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-gradle
MIT License
124 stars 51 forks source link

Multiple Gradle projects cannot be loaded #1497

Closed dougclayton closed 1 month ago

dougclayton commented 3 months ago

Extension Name: vscode-gradle Extension Version: 3.13.5 OS Version: Win11 VSCode version: 1.90.0

Describe the bug Two Java-based Gradle projects in one workspace make only one Java project show up. This does not occur with 3.13.0 (verified with repeated version toggling). It also only breaks if the java plugin is applied.

To Reproduce Create a new workspace with these files: simple1/build.gradle simple2/build.gradle

Each build.gradle just consists of the following line:

apply plugin: 'java'

Switch to 3.13.5 and run "Java: Clean Language Server Workspace".

Expected behavior Both simple1 and simple2 Java projects should be listed in "Java Projects". Instead, only simple1 shows up.

Screenshots

image

Output from "Gradle for Java"

[info] [gradle-server] Server started, listening on 32769
[info] Gradle client connected to server

Does the bug still exist if you disable all other extensions? Yes.

Additional context As mentioned, it works in 3.13.0 and first broke in 3.13.1.

dougclayton commented 3 months ago

This bug is still present as of 3.14.1.

jdneo commented 3 months ago

Do Simple1 and Simple2 have any kind of relationship, like include build?

Or they are just two independent projects?

dougclayton commented 3 months ago

They don't have any relationship. It's literally just two files in the entire workspace, each with a single line in them.

dougclayton commented 2 months ago

This bug is still present as of 3.16.0.

jdneo commented 2 months ago

Sorry, it should be related with the project scan mechanism I think: https://github.com/microsoft/vscode-gradle/blob/d45be231432c0feb2f5db8bc87230869f19f3093/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/GradleBuildServerProjectImporter.java#L59

So far, there are some workaround:

  1. Open simple1 and simple2 in two vscode windows separately.
  2. Disable the setting java.gradle.buildServer.enabled
dougclayton commented 2 months ago

Yes, agreed it's probably an issue in the scan code. Neither of your suggestions works for us, so our workaround is to downgrade to 3.13.0 but that won't last forever. Is opening a workspace with multiple Gradle projects officially supported? Because this bug doesn't require any kind of strange setup, just 2 trivial Java projects.

dougclayton commented 4 weeks ago

Can confirm this is fixed in the latest version, thanks!