Skip to content

Instantly share code, notes, and snippets.

@fernando-jascovich
Created November 9, 2016 21:02
Show Gist options
  • Select an option

  • Save fernando-jascovich/179598843bb8f73195a8eed32fff7f9d to your computer and use it in GitHub Desktop.

Select an option

Save fernando-jascovich/179598843bb8f73195a8eed32fff7f9d to your computer and use it in GitHub Desktop.
;; M-x compile support
(require 'cl)
(defun* get-closest-pathname (&optional (file "Makefile"))
(let ((root (expand-file-name "/")))
(loop for d = default-directory
then (expand-file-name ".." d)
if (file-exists-p
(expand-file-name file d)) return (replace-regexp-in-string " " "\\ " d t t)
if (equal d root) return nil)))
(require 'compile)
(defun gradleMake ()
(unless (file-exists-p "gradlew")
(set (make-local-variable 'compile-command)
(let ((mkfile (get-closest-pathname "gradlew")))
(if mkfile
(format "cd %s; ./gradlew %s" mkfile android-command)))))
(add-to-list 'compilation-error-regexp-alist
'(":compile.*?\\(/.*?\\):\\([0-9]+\\): " 1 2)))
(require 'find-lisp)
(defun get-jars-from-path (path)
"iterates recursively and return founded jars as string using ':' as sep"
"input must be build/intermediates path of gradle module"
(let (deps jars)
(setq deps (concat path "/exploded-aar"))
(setq jars (find-lisp-find-files path ".*\.jar"))
(mapconcat 'identity jars ":")))
(defun android-env (&optional command)
"Set the classpath and invokes jde"
(interactive)
(or command (setq command "installDebug"))
(setq android-command command)
(add-hook 'java-mode-hook 'gradleMake)
(add-hook 'nxml-mode-hook 'gradleMake)
(add-hook 'web-mode-hook 'gradleMake)
(add-hook 'groovy-mode-hook 'gradleMake)
(let ((mkfile (get-closest-pathname "gradlew")))
(async-shell-command (format "cd %s; ./gradlew classpath" mkfile)
"android-env"))
(load-file "~/.emacs.d/config/keys.el"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment