-
Notifications
You must be signed in to change notification settings - Fork 199
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
[Feature request] support multi-module java projects #541
Comments
This is exactly how eglot works now. Is it not correct? Lines 2629 to 2640 in 61b71ea
|
I have a project with multiple nested subrepos and 3 levels deep hierarchy. I doesn't work properly there. Current code only looks 1 level deep and doesn't open root of project. |
Oh right, indeed the single- |
so far I'm using this for supporting recursive projects: ((cl-defmethod eglot-initialization-options ((server eglot-eclipse-jdt))
"Passes through required jdt initialization options"
`(:workspaceFolders
[,@(mapcar #'eglot--path-to-uri
(let* ((root (expand-file-name (project-root (eglot--project server))))
projects
candidate)
(while (or (file-exists-p (setq candidate (expand-file-name "../pom.xml" root)))
(file-exists-p (setq candidate (expand-file-name "../build.gradle" root)))
(file-exists-p (setq candidate (expand-file-name "../.project" root))))
(setq root (file-name-directory candidate)))
(setq projects (list root)
candidate projects)
(cl-flet ((dig-deeper (dir)
(append (file-expand-wildcards (concat dir "*/pom.xml"))
(file-expand-wildcards (concat dir "*/build.gradle"))
(file-expand-wildcards (concat dir "*/.project")))))
(while (setq candidate
(cl-delete-duplicates
(mapcar #'file-name-directory (apply #'append (mapcar #'dig-deeper candidate)))
:test #'string=))
(setq projects (append projects candidate))))
projects))]
,@(if-let ((home (or (getenv "JAVA_HOME")
(ignore-errors
(expand-file-name
".."
(file-name-directory
(file-chase-links (executable-find "javac"))))))))
`(:settings (:java (:home ,home)))
(ignore (eglot--warn "JAVA_HOME env var not set")))))```
Haven't checked yet if sorting (from root to leaves) is required.
--edit: switch to pure elisp solution -- |
eglot-initialization-options should first find root of project (going up a directory and looking for pom.xml), and than scan recursively for pom.xml (if child dir has no pom.xml it should stop going further) and than add everything to :workspaceFolders.
or you could maybe allow for setting :workspaceFolders manually (for example variable containing alist of "root dir" '(list of project roots)), if you would like to pick this option I'm willing to work on a pull request for this.
The text was updated successfully, but these errors were encountered: