I've been trying to get my Emacs config for Java development working. It's pretty good - I've gotten malabar-mode working and have GNU Global working for tag browsing. The one thing I can't get working is getting semanticdb to use gnu global properly. None of my imports are found.
First, this is a Maven multi-module project with all sources checked out from the top-level root project folder. All other projects are below this one in the directory tree. There is a single GTAGS database in this root folder covering everything.
Things that work:
M-x gtags-find-tag RET symbol RET
works fine, so the database is good and global can find it.M-x cedet-gnu-global-version-check
works and reports that my version is good.M-x cedet-gnu-global-expand-filename
worksM-x semanticdb-find-test-translate-path
shows a "GNU Global Search Table" when in a Java buffer- I have the JDK source folder set as a system include folder, so core Java imports are parsed properly.
My java config is as follows (cedet initialization is earlier in the file):
(add-local-load-path "malabar/lisp")
(require 'malabar-mode)
(setq malabar-groovy-lib-dir (concat emacs-local-site-lisp "malabar/lib"))
(add-to-list 'auto-mode-alist '("\\.java\\'" . malabar-mode))
;; enable semanticdb support for gnu global
(when (cedet-gnu-global-version-check t)
(semanticdb-enable-gnu-global-databases 'java-mode))
(add-hook 'java-mode-hook
(lambda ()
(gtags-mode 1)))
(add-hook 'java-mode-hook 'flymake-mode-on)
(defun my-java-flymake-init ()
(list "javac" (list (flymake-init-create-temp-buffer-copy
'flymake-create-temp-with-folder-structure))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.java$" my-java-flymake-init flymake-simple-cleanup))
(add-hook 'java-mode-hook
'(lambda ()
(semantic-add-system-include (getenv "JAVA_HOME") 'java-mode)))