Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the java.configuration.maven.globalSettings property #1365

Closed
alantango opened this issue Apr 4, 2020 · 23 comments · Fixed by #1683 or eclipse-jdtls/eclipse.jdt.ls#1586
Closed
Assignees

Comments

@alantango
Copy link

I'm very close to make the switch to VSCode from Eclipse, this is the last hurdle, but one I can't walk around. Please help.

The Problem: A working Maven project that builds fine with command line mvn will have many errors in pom once loaded in VS code. POM errors result in classes / types in dependency libraries not resolved in the editor.

Note: This seems to happen only within a corporate network using our own internal central repo server (like "https://internal.myfirm.com/repository/maven/"). Same code works at home, though I don't use any customized maven setting files like those at work.

Screenshot of the project error here:

vscode-err-mytest1

My guess is as a result of the error, no .classpath file is generated, and no dependencies are shown on the project tree on the left panel.

What I don't understand is why would VSCode complain about connecting to the public Maven central repo while my maven settings point to our own repo server?

If I replace both settings.xml with standard plain setting files, it pulls dependencies from the public maven central https://repo.maven.apache.org/maven2 and works just fine. Obviously I cannot do that in practice as I'm required to use corporate maven repo.

Note:

  • mvn command works fine standalone, recognizing the customized maven setting files, downloading dependencies from the internal repo.
  • No override of any maven settings is put into VScode
  • Environment variables are set on the machine:
    M2=C:\dev\maven\3.3.9\bin
    M2_HOME=C:\dev\maven\3.3.9

Environment
OS: Windows10 build 1809, 64-bit
VSCode Version: 1.43.2
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0

Reference Files

@snjeza
Copy link
Contributor

snjeza commented Apr 4, 2020

@alantango How did you create your SSL certificate on https://internal.myfirm.com/repository/maven/?
See #455 (comment)

@alantango
Copy link
Author

@snjeza Thanks. I don't know how it was generated but it's an enterprise internal cert (the name I used above is masked for obvious reasons). You think it has something to do with the cert?

@snjeza
Copy link
Contributor

snjeza commented Apr 4, 2020

You think it has something to do with the cert.

Does the issue happen in Eclipse?
Do you use a proxy?

@alantango
Copy link
Author

@snjeza It works fine with Eclipse, no proxy used in Eclipse, the repo server is within the corp network. Eclipse's Maven setting points to the exact same setttings.xml files as installed on my machine.

@snjeza
Copy link
Contributor

snjeza commented Apr 4, 2020

@alantango Could you send your VS Code settings.json and Maven settings.xml path?

@alantango
Copy link
Author

@snjeza Here:
C:\Users\user-name\AppData\Roaming\Code\User\settings.json
C:\Users\user-name.m2\setttings.xml

Here is the entire settings.json:


{
    "workbench.startupEditor": "newUntitledFile",
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    "window.zoomLevel": 0,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "java.configuration.checkProjectSettingsExclusions": false,
    "java.configuration.maven.userSettings": "",
    "java.errors.incompleteClasspath.severity": "ignore",
    "breadcrumbs.enabled": false,
    "maven.executable.preferMavenWrapper": true,
    "http.proxyStrictSSL": true,
    "java.dependency.packagePresentation": "hierarchical",
    "maven.pomfile.autoUpdateEffectivePOM": true,
    "maven.terminal.useJavaHome": true,
    "telemetry.enableCrashReporter": false,
    "telemetry.enableTelemetry": false,
    "workbench.settings.enableNaturalLanguageSearch": false,
    "extensions.autoUpdate": false,
    "workbench.enableExperiments": false
}

@snjeza
Copy link
Contributor

snjeza commented Apr 4, 2020

@alantango could you try to add the following VS Code settings:

"java.configuration.maven.userSettings": "C:\\Users\\user-name.m2\\setttings.xml",

or

"java.configuration.maven.userSettings": "C:\\Users\\user-name\\.m2\\settings.xml",

@alantango
Copy link
Author

@snjeza Tried both and problem remains the same.

Btw I also tried a popular suggestion of command "Java: clean the Java Language server workspace" -> Restart and clean, with or without above changes, no effect.

@snjeza
Copy link
Contributor

snjeza commented Apr 4, 2020

Could you show the next Eclipse Preferences:
General>Network Connections
Maven>User Settings

@snjeza
Copy link
Contributor

snjeza commented Apr 4, 2020

@alantango which version of Eclipse are you using?

@alantango
Copy link
Author

Eclipse Version: Oxygen.3a Release (4.7.3a)
Build id: 20180405-1200

eclipse-settings

@snjeza
Copy link
Contributor

snjeza commented Apr 5, 2020

Could you show the General>Network Connections Eclipse Preferences?

@snjeza
Copy link
Contributor

snjeza commented Apr 5, 2020

VS Code doesn't use global maven settings.
Could you try append your global settings to your user settings?

@alantango
Copy link
Author

@snjeza Oh that's interesting...didn't know that. Anyways just tried, problem remains. I made sure mvn command standalone still works.

@snjeza
Copy link
Contributor

snjeza commented Apr 5, 2020

Anyways just tried, problem remains. I made sure mvn command standalone still works.

@alantango could you try the following in Eclipse:

  • append your global settings to your user settings
  • remove the global settings preference

Could you also check Eclipse IDE 2020‑03?

@alantango
Copy link
Author

@snjeza Current Eclipse works with merged global setting files. But vscode still won't work. Don't plan to change to Eclipse 2020-03.

@snjeza
Copy link
Contributor

snjeza commented Apr 5, 2020

@snjeza Current Eclipse works with merged global setting files. But vscode still won't work. Don't plan to change to Eclipse 2020-03.

@alantango Could you send your VS Code log when using merged global settings in VS Code?

@alantango
Copy link
Author

Could you send your VS Code log when using merged global settings in VS Code?
See attached. Same errors seen in my original post's attached log.
vscode-jdt2.log

@snjeza
Copy link
Contributor

snjeza commented Apr 5, 2020

@alantango could you send the output of the following command:

type C:\Users\user-x\.m2\setttings.xml 

You have three 't' in settings.xml

@alantango
Copy link
Author

@snjeza Ahh that was it. I corrected and file name and it worked, then I removed the setting altogether and it worked as well. Looking at the thread history, that wrong file name 'setttings.xml' was added BEFORE I merged the global settings file. It can either be empty or put in with a correct file name.

Thank you very much!

So the key is what you said earlier: VS Code doesn't use global maven settings. I would strongly suggest making that statement prominently clear on the README of this extension.

I believe this is also the solution to #1232.

@snjeza
Copy link
Contributor

snjeza commented Apr 5, 2020

@fbricon should we add the java.configuration.maven.globalSettings property?

@lucastheisen
Copy link

@snjeza , one more voice here, but:

should we add the java.configuration.maven.globalSettings property?

yes. A colleague and I spent about 3 hours digging around in all the wrong places to finally discover this comment chain. It would be best to support globalSettings as its a very highly used maven idiom. But if you dont, it would be nice to put that somewhere in the documentation.

@yoshiya8
Copy link

yoshiya8 commented Aug 14, 2020

Yeah this bit me real bad! Please make a java.configuration.maven.globalSettings property available and have it default to ${M2_HOME}/conf/settings.xml

@snjeza snjeza changed the title VSCode cannot resolve POM dependencies against alternative Maven repo server Add the java.configuration.maven.globalSettings property Aug 14, 2020
@snjeza snjeza self-assigned this Aug 14, 2020
@rgrunber rgrunber added this to the End October 2020 milestone Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants