vscode-java
vscode-java copied to clipboard
Self referencing maven modules should not trigger an infinite loop in vscode
Vscode enters an infinite loop while trying to compile a falsy module setup. It should instead break the build should break with an error stating that a module is self-referencing itself the same way the maven cli report it.
Environment
- Operating System: OSX BIg Sur
- JDK version: OpenJDK 11.0.8 2020-07-14
- Visual Studio Code version: [Version: 1.56.2 Commit: 054a9295330880ed74ceaedda236253b4f39a335]
- Java extension version:
Steps To Reproduce
- Create a parent maven project with packaging type
pom
-parent
- Create a submodule (module-1) project with the packaging type '
jar
' in the previous parent project - Add a dependency of
module-1
inparent
with the save version (${project.version}) - See the error: Vscode will enter an infinite loop trying to resolve the dependency
Sample project reproducing the error
Current Result
The build will never get past the 339/1000 as displayed in the console (infinite loop)

Expected Result
Build should terminate with error as done bymaven when using the cli.

Additional Informations
I face with same error (infinite java building) in multi module maven project with vscode + java in dev containers. My dev containers JSON is :
{ "name": "Java", "build": { "dockerfile": "Dockerfile", "args": { "VARIANT": "0.151-8", "INSTALL_MAVEN": "true", "INSTALL_GRADLE": "false", "INSTALL_NODE": "false", "NODE_VERSION": "lts/*" } },
I am seeing the same behavior without self-referencing modules. Perhaps a different issue, please feel free to split into a different issue.
Some of the projects have Maven plugins that run in the generate-sources
phase and produce source code in ./target/generated-sources
. VScode behavior in this case is "refresh workspace", followed by "try building again", which in turn results in generate-sources
targets re-executed and the whole thing starts again.
I attempted disabling the M2E mapping for the plugins that generate code to avoid this problem:
<executions>
<execution>
-<?m2e execute onConfiguration,onIncremental?>
+<?m2e execute?>
...
</execution>
...
Per M2E documentation onConfiguration, onIncremental
means that the plugin should run every time the project configuration changes and also with every incremental build. It looks like that onIncremental
causes the problem here, sending vscode Maven integration into infinite loop. I didn't have a chance to confirm if Eclipse itself has a different behavior, but since other folks in my team didn't see any issues with it, and some use Eclipse, I'd suspect this may be vscode-specific.
Edit: The solution above is less than ideal for a number of reasons, notably now code generation won't run incrementally at all, which means one needs to do
mvn clean generate-sources
in the console periodically.