diff --git a/emacs/.emacs.d/config/init-run-command.el b/emacs/.emacs.d/config/init-run-command.el index 3ff8c12..a8b6b1d 100644 --- a/emacs/.emacs.d/config/init-run-command.el +++ b/emacs/.emacs.d/config/init-run-command.el @@ -215,6 +215,77 @@ (list :command-name "install" :command-line (format "pip install -r %s" (buffer-file-name)))))) + (defun run-command-recipe-maven () + (when-let* ((root-dir (or (projectile-project-root) default-directory)) + (local-pom-dir (locate-dominating-file default-directory "pom.xml")) + (project-dir (locate-dominating-file root-dir "pom.xml")) + (commands (list + (list :command-name "validate" + :command-line "mvn validate" + :working-dir local-pom-dir) + (list :command-name "compile" + :command-line "mvn compile" + :working-dir local-pom-dir) + (list :command-name "clean compile" + :command-line "mvn clean compile" + :working-dir local-pom-dir) + (list :command-name "test" + :command-line "mvn test -DfailIfNoTests=false" + :working-dir local-pom-dir) + (list :command-name "package" + :command-line "mvn package" + :working-dir local-pom-dir) + (list :command-name "verify" + :command-line "mvn verify" + :working-dir local-pom-dir) + (list :command-name "install" + :command-line "mvn install" + :working-dir local-pom-dir) + (list :command-name "install (skip tests)" + :command-line "mvn install -DskipTests" + :working-dir local-pom-dir) + (list :command-name "deploy" + :command-line "mvn deploy" + :working-dir local-pom-dir) + (list :command-name "clean" + :command-line "mvn clean" + :working-dir local-pom-dir) + (list :command-name "exec:java" + :command-line "mvn exec:java" + :working-dir local-pom-dir) + (list :command-name "clean compile exec:java" + :command-line "mvn clean compile exec:java" + :working-dir local-pom-dir) + (when-let ((test-class (and (buffer-file-name) + (let ((case-fold-search nil)) + (string-match-p ".*\\(Test\\|IT\\).*\\.java$" + (buffer-file-name))) + (fboundp 'dap-java-test-class) + (dap-java-test-class)))) + (list :command-name "test this class" + :command-line (format "mvn test -DfailIfNoTests=false -Dtest=%s" test-class) + :working-dir local-pom-dir)) + (when-let ((test-method (and (buffer-file-name) + (let ((case-fold-search nil)) + (string-match-p ".*\\(Test\\|IT\\).*\\.java$" + (buffer-file-name))) + (fboundp 'dap-java-test-method-at-point) + (dap-java-test-method-at-point t)))) + (list :command-name "test this method" + :command-line (format "mvn test -DfailIfNoTests=false -Dtest=%s" test-method) + :working-dir local-pom-dir))))) + (if (s-equals? local-pom-dir project-dir) + commands + (-concat commands + (-map (lambda (cmd) + (when cmd + (-> (-copy cmd) + (plist-put :command-name + (format "%s (root POM)" + (plist-get cmd :command-name))) + (plist-put :working-dir project-dir)))) + commands))))) + (defun get-cargo-commands (dir) (when (executable-find "cargo") (with-temp-buffer @@ -307,6 +378,7 @@ run-command-recipe-nosetests run-command-recipe-web-ext run-command-recipe-pip + run-command-recipe-maven run-command-recipe-cargo run-command-recipe-rake run-command-recipe-scripts)))