Repository navigation
Running test causes repeated Java rebuilds #1839
Copy link
Copy link
Closed
microsoft/vscode-gradle
#1794Description
The problem is that when running a test, for some reason, this causes the Java build server to rebuild repeatedly. Every time that happens, it causes the tests to reload also.
On larger projects, this rebuild gets rather violent. I suspect this may be because the rebuild is trigger for each subproject, as the time between rebuilds is much shorter on larger projects. This requires a cleaning of the Java workspace entirely, as it will slow down the system to a crawl.
This might be related to #1787.
Sample project to replicate:
Steps to replicate:
- Install the extensions
- Clean the Java workspace
- Open
LinkedListTest.java - Run any test
- Observe the
Testingtab
Workaround:
- Set
"java.gradle.buildServer.enabled": "off",
Other problems I noticed:
- Missing classpath entries had to be fixed with java.test.config (in the sample project,
{workspace}/sample-file/build/custom-libs/sample.jarwas missing which works when running the test from the command line) - Sometimes a classpath entry will be truncated to be incorrect absolute paths, e.g.,
/sample-bad-classpath/list/bin
Setup:
- Java 21 (Corretto)
- Gradle 9.3.1
- WSL 2.6.3.0
- Ubuntu 24.04.4
- VSCode 1.109.5
- WSL VSCode Extensions:
- Container Tools - ms-azuretools.vscode-containers - version 2.4.1
- Debugger for Java - vscjava.vscode-java-debug - version 0.58.5
- Gradle for Java - vscjava.vscode-gradle - version 3.17.2
- Language Support for Java(TM) by Red Hat - redhat.java - version 1.52.0
- Partial Diff - ryu1kn.partial-diff - version 1.4.3
- Test Runner for Java - vscjava.vscode-java-test - version 0.44.0
- XML - redhat.vscode-xml - version 0.29.0
- Windows VSCode Extensions:
- vscode-icons - vscode-icons-team.vscode-icons - version 12.17.0
- WSL - ms-vscode-remote.remote-wsl - version 0.104.3
Remote settings.json:
"[java]": {
"editor.pasteAs.enabled": false,
},
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "/usr/lib/jvm/java-17-amazon-corretto"
},
{
"name": "JavaSE-21",
"path": "/usr/lib/jvm/java-21-amazon-corretto"
},
],
"java.jdt.ls.java.home": "/usr/lib/jvm/java-21-amazon-corretto",
"java.import.gradle.java.home": "/usr/lib/jvm/java-21-amazon-corretto",Please let me know if I need to create the issue on another repository instead.
Reactions are currently unavailable
Activity
github-actions commentedon Feb 23, 2026
Hi Trevor Kropp (@kropptrevor), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
Possible Solutions
Disable VS Code’s auto-build before running tests. Add to your settings:
This stops Gradle projects from rebuilding on each test invocation (you’ll need to rebuild manually).
Try enabling the Gradle Build Server (instead of Buildship) to see if it reduces per-subproject rebuild churn:
Then run Java: Clean Java Language Server Workspace and reload the window.
Open only the module containing your tests (rather than the full multi-project workspace) when running tests.
Duplicate Issue
This appears to be the same root problem as:
Other references with low confidence
The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!
wenytang-ms commentedon Mar 3, 2026
Trevor Kropp (@kropptrevor) thank you for report this issue, we also noticed this issue, and ship a fix pre-release 0.44.2026030208 to
vscjava.vscode-java-test, and the pre-release 3.17.2026022802 toGradle for Java. please install these two bits and verify this issue. thanks!kropptrevor commentedon Mar 3, 2026
On bigger projects, I'm still getting the issue where it's constantly rebuilding after running a test. The difference is that is doesn't reload the tests every time.
I should mention that when running a test, it prompts:
which I'm starting to think is related in some way.
I also noticed that the rebuilding issue is causing everything to break with the tests.
Here is one of the sets of errors (doesn't always show up):
Missing system library
Here is another:
Error in Java Model
wenytang-ms commentedon Mar 5, 2026
Trevor Kropp (@kropptrevor)
we have shipped a pre-release version 0.44.2026030502 for
test runner for java, please install the latest bits with latest pre-release version of Gradle for java to have check this issue, thanks!kropptrevor commentedon Mar 5, 2026
I tried that and it's still happening.
I found this issue, which I think might be the cause: redhat-developer/vscode-java#4307
I tested this by creating a main method and running it without having the vscode-java-test plugin installed. The rebuilding problem still showed up.
wenytang-ms commentedon Mar 11, 2026
Trevor Kropp (@kropptrevor)
I tested this based on the version you provided. The test was done in WSL on Windows, with the relevant extensions installed as well. From the GIF, it looks like things are working as expected. Could you please double‑check on your side? or can you share your vedio record?
versions
fix: suppress auto-build during BSP didChange to prevent infinite reb…
fix: prevent infinite rebuild loop after BSP didChange notifications
wenytang-ms commentedon Apr 8, 2026
Hi Trevor Kropp (@kropptrevor), we've found the root cause. It’s a bit complex, so we focused on fixing the essential rebuild logic first in this new release. Could you please verify it with this version? Thank you!
vscode-gradle 3.17.2026040802kropptrevor commentedon Apr 8, 2026
wenyt (@wenytang-ms) I installed the latest pre-release Test Runner for Java with the latest pre-release Gradle for Java (kept Language Support for Java(TM) by Red Hat on the release version since the pre-release seems to always be broken).
The issue reported here is fixed. I don't see any repeated rebuilds. There are still some issues with test detection after running, particularly with nested tests, but those are not in the scope of this issue.
Thanks for your diligence.
wenytang-ms commentedon Apr 9, 2026
Trevor Kropp (@kropptrevor) thank you for helping verify this issue, we will ship these bits as stable later.
if you have other issues, just submit.
Now I going to close this issue. feel free to reopen it once this issue repro.
fix: prevent infinite rebuild loop after BSP didChange notifications (m…