Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 689
Luciano Avatar asked Jan 17 '26 12:01

Luciano


1 Answers

VSCode setting ID: java.configuration.maven.userSettings

  1. In VSCode, go to Preferences > Settings > Workspace
  2. Search 'maven'
  3. Set 'Java > Configuration > Maven: User Settings' to ./settings.xml to make VSCode use the local settings.xml of the project
  4. Restart VSCode if needed

Screenshot

like image 53
Aloha Avatar answered Jan 20 '26 01:01

Aloha