'Vscode with custom settings.xml Maven file per project in a workspace
I have a Vscode workspace with a bunch of Maven projects, and which one has its own Maven settings.xml file.
As each project has its own settings file with the same name but in its own root folder I got success configuring both the workspace as each of the projects with such an option: {"maven.executable.options": "-s my_settings.xml"}.
Although, I can run successfully any of Maven commands for all projects, Vscode reports problems in the pom.xml files about missing artifacts and the same errors are reported when I run tests from the "Testing" in the Side Bar.
When I copy one of the project's settings file to the ~/.m2/settings.xml that given project works fine, no errors at all.
So, I conclude Vscode doesn't respect the "maven.executable.options" for all of project operations inside IDE, like tests and maybe others operations but only for directly launched Maven commands.
I don't want to merge all those settings.xml files into a big one in my local ~/.m2/settgins.xml each time I have to open a given set of projects.
Is there a way to teach Vscode to use different settings.xml for each project and make it work properly in all Vscode operations (not only Maven commands)?
Solution 1:[1]
you can use
mvn --settings settings.xml clean install
to individually point respective settings.xml for each java app
Solution 2:[2]
VSCoset setting ID: java.configuration.maven.userSettings
- In VSCode, go to Preferences > Settings > Workspace
- Search 'maven'
- Set 'Java > Configuration > Maven: User Settings' to make VSCode use the local settings.xml of the project.
- Restart VSCode if needed enter image description here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Abhishek Dash |
| Solution 2 | Aloha |
