vscode-maven
vscode-maven copied to clipboard
Maven for Java cannot set settings.xml for different workspace
As we know, the extension Language Support for Java(TM) by Red Hat can use with different java project and specify different settings.xml。So,I hope the Maven for Java extension can support this.
It's set to machine
scope for security reason. BTW, what's your use case?
Do you want to execute all maven commands with --settings path-to-local-settings.xml
appended? If so, setting maven.executable.options
can help. Or you can directly leverage .mvn/maven.config
See https://maven.apache.org/configure.html#mvn-maven-config-file
It's set to
machine
scope for security reason. BTW, what's your use case?Do you want to execute all maven commands with
--settings path-to-local-settings.xml
appended? If so, settingmaven.executable.options
can help. Or you can directly leverage.mvn/maven.config
See https://maven.apache.org/configure.html#mvn-maven-config-file
Hi Eskibear, I find maven.executable.options doesn't work even when I set --settings path-to-local-settings.xml
, and when clicking maven install
button, it still download dependencies following the default setting.xml, not mine. similar issue is raised in stackflow: Vscode doesn't respect the "maven.executable.options"
Let's figure out whether it's related to VS Code Maven extension or Maven CLI itself.
I find maven.executable.options doesn't work even when I set --settings path-to-local-settings.xml
Did it send the expected command line (mvn .... --settings path-to-local-settings.xml) to the terminal? If so, then VS Code Maven extension had done its job correctly. In this case, it should be the same whether you run mvn command inside/outside vscode. Then culprit that I can think of might be either a malformed/invalid local-settings.xml or even malformed Maven CLI.
Did it send the expected command line (mvn .... --settings path-to-local-settings.xml) to the terminal?
Thanks. I find maven extension works as expected, and my issue is not due to the maven-plugin. I figure this issue out that the command mvn ... -s local-settings.xml
doesn't respect the local-settings.xml when there's already a settings.xml in the global path, i.e., in $MAVEN_HOME/conf/settings.xml
.
When I delete the settings.xml in global path, mvn ... -s local-settings.xml
works properly.
I'm having a somewhat similar issue, but I want to use various setting.xml files at the base of different java repos.
Is there a way to access the absolute path of the java repo? Is there a variable I can reference in the maven.executable.options
setting?
this would be nice, also maybe if specifying a local repository settings.xml file (in the root) would take precendence over /.m2 settings as its not easy to change
After a quick search, I find a promising solution, using .mvn/maven.config
: https://stackoverflow.com/a/48583079
The benefit is, this solution is not tied to vscode-maven, meaning that it's still working even if you are not using vscode.