Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
How to `lsp-java-update-server` with custom Maven `settings.xml`? #140
Apparently, I'm behind corporate proxy and with custom SSL certificates which cannot be verified properly:
Normally, what I do with other tools, I drop SSL certificate verification as there are always options to do so. For Maven, I found out that adding
does not help either. Any ideas how to go about it?
mvn -Djdt.js.server.root=/home/kyoncho/.emacs.d/eclipse.jdt.ls/server/ -Djunit.runner.root=/home/kyoncho/.emacs.d/eclipse.jdt.ls/test-runner/ -Djunit.runner.fileName=junit-platform-console-standalone.jar -Djava.debug.root=/home/kyoncho/.emacs.d/eclipse.jdt.ls/server/bundles clean package -Djdt.download.url=http://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz
lsp-java is doing pretty much the same but it does not rely on mvn being installed (it uses mvnw).
Everything is possible but we have pretty limited resources and we often settle with the workaround, there are 100+ open issues in the organization and dozens of missing features and we have to prioritize.
Anyway, once you confirm that mvn solution works, you may download the content of https://github.com/emacs-lsp/lsp-java/tree/master/install and try to figure out why mvnw does not pick the ~/.m2/settings.xml.
I found out that
Would you mind to add
Furthermore, the main change is to support both
(defun lsp-java--prepare-mvnw () "Download mvnw." (let ((mvn-executable (if (string-equal system-type "windows-nt") "mvnw.cmd" "mvnw")) (downloader ".mvn/wrapper/MavenWrapperDownloader.java") (properties ".mvn/wrapper/maven-wrapper.properties")) (mkdir ".mvn/wrapper/" t) (copy-file "~/.m2/jvm.config" ".mvn/jvm.config") (copy-file "~/.m2/settings.xml" ".mvn/settings.xml") (f-write-text "-s .mvn/settings.xml" 'utf-8 ".mvn/maven.config") (url-copy-file (concat lsp-java--download-root mvn-executable) mvn-executable t) (url-copy-file (concat lsp-java--download-root downloader) downloader t) (url-copy-file (concat lsp-java--download-root properties) properties t) (if (string= system-type "windows-nt") mvn-executable (concat "sh " mvn-executable))))
seems to be ill-formed. This logic will never use
It is a typo - it should be - use mvn if present otherwise fallback to downloading and configuring mvnw. Fixed with 1502492 . I was thinking also about packaging mvnw as part lsp-java. I might be wrong but this will fix this issue too since you will be able to define .mvn/jvm-settings file since it will be in a well-known location. Also, I was planning to create a job which will package and publish all lsp-java dependencies so the manual installation will be download and unzip in case the automatic download does not work.
For your suggestion, it will probably work but requires more work in order to be generic. E. g. ...
... but user settings might not be located on this location, etc. I am a bit concerned that this will increase the overall complexity of the installation.
I was thinking of it to be more like a best effort approach:
(copy-file "~/.m2/jvm.config" ".mvn/jvm.config") (copy-file "~/.m2/settings.xml" ".mvn/settings.xml")
That is copy them if any of them are there because this is what one would expect probably not to notice any difference between
For future visitors and/or for your consideration, sharing my generic snippet to generate
(when (zerop (length (getenv "MAVEN_OPTS"))) (let (maven-opts) (dolist (scheme '("http" "https")) (url-scheme-register-proxy scheme) (let ((proxy (cdr (assoc scheme url-proxy-services))) (urlobj nil)) (unless (zerop (length proxy)) (save-match-data (cond ((string-match "^\\([^:]+\\):\\([0-9]+\\)$" proxy) (setq urlobj (url-generic-parse-url nil)) (setf (url-type urlobj) scheme) (setf (url-host urlobj) (match-string 1 proxy)) (setf (url-port urlobj) (string-to-number (match-string 2 proxy)))) ((string-match url-nonrelative-link proxy) (setq urlobj (url-generic-parse-url proxy)) (setf (url-type urlobj) scheme) (setf (url-target urlobj) nil)) (t (setq urlobj (url-generic-parse-url nil)) (setf (url-type urlobj) scheme) (setf (url-host urlobj) proxy)))) (setq maven-opts (nconc maven-opts `(,(format "-D%s.proxyHost=%s" (url-type urlobj) (url-host urlobj)) ,(format "-D%s.proxyPort=%d" (url-type urlobj) (url-port urlobj)))))))) (setenv "MAVEN_OPTS" (mapconcat #'identity maven-opts " "))))
All of this works well with standard