vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Java plugin rebuilds project code everytime i instruct maven to compile

Open palminha opened this issue 6 months ago • 15 comments

I have a java/maven/spring project.

The IDE is showing the JAVA build option in the bottom bar... it seems it using the JAVA plugin to build the project

Image

when i try to build my project using maven, the JAVA tries to rebuild in parallel and i get a lot of problems with the compilation

Image

palminha avatar Jul 04 '25 07:07 palminha

What happens if you add the setting "java.autobuild.enabled": false ? Does that solve the build issues ? It might be that your Maven build makes certain modifications that cause the Java support to detect certain changes that then trigger the autobuild. With this setting you would have to manually trigger the rebuild but may be worth it if it solves the conflict.

rgrunber avatar Jul 04 '25 13:07 rgrunber

What happens if you add the setting "java.autobuild.enabled": false ? Does that solve the build issues ? It might be that your Maven build makes certain modifications that cause the Java support to detect certain changes that then trigger the autobuild. With this setting you would have to manually trigger the rebuild but may be worth it if it solves the conflict.

@rgrunber, that's a good mitigation, thanks. However, I won't be able to access the "problems" tab, or other functional features, that it seems it requires the java plugin...

Returning to my original point: resolve the issue with Maven-Java not functioning correctly.

palminha avatar Jul 05 '25 10:07 palminha

"java.autobuild.enabled": false doesn't block the code to be built by java plugin when i open vscode

palminha avatar Jul 05 '25 11:07 palminha

What do you mean by accessing the problems tab ? Even if you disabled auto-build, you can still manually call Java: Rebuild Projects or Java: Force Java Compilation to have the problems view populated with issues. Is that what you meant ?

rgrunber avatar Jul 07 '25 21:07 rgrunber

What do you mean by accessing the problems tab ? Even if you disabled auto-build, you can still manually call Java: Rebuild Projects or Java: Force Java Compilation to have the problems view populated with issues. Is that what you meant ?

If i turn "java.autobuild.enabled": false and build the project using maven (manually select it), the problems view is not populated with results

palminha avatar Jul 08 '25 17:07 palminha

Would you be able to share the project ? Even if you could only share the project without the sources, and could mention the kind of problems that don't get reflected in the problems view, would help.

rgrunber avatar Jul 15 '25 20:07 rgrunber

Would you be able to share the project ? Even if you could only share the project without the sources, and could mention the kind of problems that don't get reflected in the problems view, would help.

@rgrunber thanks for following up... I have open a separate topic about that specific issue: #4117

palminha avatar Jul 16 '25 08:07 palminha

If this particular issue now remains about a conflict between the Java VS Code extension and the calling of a build tool from commandline (or some other way), then this seems very similar to https://github.com/redhat-developer/vscode-quarkus/issues/999 . That one was about using the Quarkus tooling & Java extension ,but the idea is the same. Running a build command (even within the terminal of VS Code) while the Java extension is set to autobuild can cause conflicts.

rgrunber avatar Jul 16 '25 14:07 rgrunber

If this particular issue now remains about a conflict between the Java VS Code extension and the calling of a build tool from commandline (or some other way), then this seems very similar to redhat-developer/vscode-quarkus#999 . That one was about using the Quarkus tooling & Java extension ,but the idea is the same. Running a build command (even within the terminal of VS Code) while the Java extension is set to autobuild can cause conflicts.

@rgrunber the case here in #4117 is not related to autbuild since I disabled it following your initial suggestion ("java.autobuild.enabled": false ! Thanks for the tip!

The question is also not related to running a specific command line tool... as you can see in #4117 i trigger the build using maven, and I expect the JAVA results are properly updated ("java.import.maven.enabled": true)

palminha avatar Jul 16 '25 14:07 palminha

Last time I try to exclude in watch and it works can you try @palminha "files.watcherExclude": { "/node_modules/": true, "/target/": true, "/build/": true, "/.git/": true, "/.idea/": true },

tinhtran19 avatar Aug 06 '25 04:08 tinhtran19

I also face this problem now. It was working fine for months. But now maven and and this Java-Plugin fighting against each other. I'm aware, that maven builds in a (VS-Code-) terminal can couse conflicts. That's why I start my Maven builds through the Maven for Java plugin. I thought, that this stops autobuilds while maven is running? As I said, this was working fine for months.

maroony avatar Aug 29 '25 07:08 maroony

@maroony , what version of vscode-java are you running ? Is it the pre-release version ? Nothing has been released since the end of July. Running the build through the "Maven for Java" plugin is just a convenient way to run it the same way that would be done in terminal/commandline.

rgrunber avatar Aug 29 '25 12:08 rgrunber

@rgrunber VSCode 1.103.2, Maven for Java 0.44.0, Language support for Java 1.44.0.

maroony avatar Aug 29 '25 13:08 maroony

I have the same issue. As @maroony said, it wasn't a problème a few weeks / months ago. From my perspective, it was "breaking not down", meaning that we were lucky that it was working properly.

Right now, when launching a build with vscode-maven, then vscode-java starts to rebuild immediatly in the same time, and the Maven build fails most of the time because of that. Sometimes, even mvn clean fails, unable to delete target/ content properly... So, to be able to work in good conditions, I keep a settings tab, opened all the time, focused on "java.autobuild", so I activate while developing (to keep the IDE up to date) and I disable it when I need to build with Maven (ex : running tests with Cucumber and / or JaCoCo, or a mvn -U clean compile to get the latest versions of my dependencies).

Like @palminha said, here or in another issue, all modern Java projects build with Maven / Gradle. So I'm wondering how is this possible that both vscode-java and vscode-maven teams didn't have any communication about the building process to coordinate their work in order to have a flawless integration of each other's build process.

I use : VSCode 1.105.1 / vscode-java 1.46.0 / vscode-maven 0.44.0

Maze-fr avatar Oct 20 '25 09:10 Maze-fr

I have the same issue. As @maroony said, it wasn't a problème a few weeks / months ago. From my perspective, it was "breaking not down", meaning that we were lucky that it was working properly.

Right now, when launching a build with vscode-maven, then vscode-java starts to rebuild immediatly in the same time, and the Maven build fails most of the time because of that. Sometimes, even mvn clean fails, unable to delete target/ content properly... So, to be able to work in good conditions, I keep a settings tab, opened all the time, focused on "java.autobuild", so I activate while developing (to keep the IDE up to date) and I disable it when I need to build with Maven (ex : running tests with Cucumber and / or JaCoCo, or a mvn -U clean compile to get the latest versions of my dependencies).

@maroony i disable the java build with "java.autobuild.enabled": false and i'm now only using maven and waiting for this issue to be released: https://github.com/microsoft/vscode-maven/issues/1098

palminha avatar Oct 21 '25 18:10 palminha