Compare commits

...

2 Commits

Author SHA1 Message Date
Jeremy Dormitzer
344ab6b686 Configure dap-mode debugging for Java 2022-04-20 15:53:36 -04:00
Jeremy Dormitzer
667ed940ef Fix run-command maven recipe to work with multi module projects 2022-04-20 15:53:20 -04:00
3 changed files with 32 additions and 4 deletions

View File

@ -62,6 +62,13 @@
:custom :custom
(lsp-ui-doc-show-with-cursor t)) (lsp-ui-doc-show-with-cursor t))
;; Integrated debugger
(use-package dap-mode
:commands (dap-debug dap-debug-edit-template dap-mode)
:config
(add-hook 'dap-stopped-hook
(lambda (arg) (call-interactively #'dap-hydra))))
;; Some compilation-mode conveniences ;; Some compilation-mode conveniences
(use-package compile (use-package compile
:straight (:type built-in) :straight (:type built-in)

View File

@ -7,6 +7,23 @@
(use-package lsp-java (use-package lsp-java
:hook (java-mode . lsp-deferred)) :hook (java-mode . lsp-deferred))
(defvar java-debug-map (make-sparse-keymap))
(general-def java-mode-map
"C-c d" '(:keymap java-debug-map :which-key "debug"))
(general-def java-debug-map
"d" 'dap-java-debug
"t" 'dap-java-debug-test-method
"c" 'dap-java-debug-test-class)
(with-eval-after-load 'dap-java
(setq dap-java-test-additional-args '("-n" "\".*(Test|IT).*\"")))
(defun jdormit-java-setup ()
(require 'dap-java)
(dap-mode))
(add-hook 'java-mode-hook 'jdormit-java-setup)
(use-package protobuf-mode) (use-package protobuf-mode)
(provide 'init-java) (provide 'init-java)

View File

@ -216,7 +216,8 @@
:command-line (format "pip install -r %s" (buffer-file-name)))))) :command-line (format "pip install -r %s" (buffer-file-name))))))
(defun run-command-recipe-maven () (defun run-command-recipe-maven ()
(when-let ((project-dir (locate-dominating-file default-directory "pom.xml"))) (when-let* ((root-dir (or (projectile-project-root) default-directory))
(project-dir (locate-dominating-file root-dir "pom.xml")))
(list (list
(list :command-name "validate" (list :command-name "validate"
:command-line "mvn validate" :command-line "mvn validate"
@ -224,8 +225,11 @@
(list :command-name "compile" (list :command-name "compile"
:command-line "mvn compile" :command-line "mvn compile"
:working-dir project-dir) :working-dir project-dir)
(list :command-name "clean compile"
:command-line "mvn clean compile"
:working-dir project-dir)
(list :command-name "test" (list :command-name "test"
:command-line "mvn test" :command-line "mvn test -DfailIfNoTests=false"
:working-dir project-dir) :working-dir project-dir)
(list :command-name "package" (list :command-name "package"
:command-line "mvn package" :command-line "mvn package"
@ -251,7 +255,7 @@
(fboundp 'dap-java-test-class) (fboundp 'dap-java-test-class)
(dap-java-test-class)))) (dap-java-test-class))))
(list :command-name "test this class" (list :command-name "test this class"
:command-line (format "mvn test -Dtest=%s" test-class) :command-line (format "mvn test -DfailIfNoTests=false -Dtest=%s" test-class)
:working-dir project-dir)) :working-dir project-dir))
(when-let ((test-method (and (buffer-file-name) (when-let ((test-method (and (buffer-file-name)
(let ((case-fold-search nil)) (let ((case-fold-search nil))
@ -259,7 +263,7 @@
(fboundp 'dap-java-test-method-at-point) (fboundp 'dap-java-test-method-at-point)
(dap-java-test-method-at-point t)))) (dap-java-test-method-at-point t))))
(list :command-name "test this method" (list :command-name "test this method"
:command-line (format "mvn test -Dtest=%s" test-method) :command-line (format "mvn test -DfailIfNoTests=false -Dtest=%s" test-method)
:working-dir project-dir))))) :working-dir project-dir)))))
(defun get-cargo-commands (dir) (defun get-cargo-commands (dir)