[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/javaimp-gradle 4346648 1/2: Make javaimp-maven work again
From: |
Filipp Gunbin |
Subject: |
[elpa] scratch/javaimp-gradle 4346648 1/2: Make javaimp-maven work again |
Date: |
Thu, 24 Oct 2019 07:56:49 -0400 (EDT) |
branch: scratch/javaimp-gradle
commit 4346648f77ead6a80381688bcfde85c82d7715cf
Author: Filipp Gunbin <address@hidden>
Commit: Filipp Gunbin <address@hidden>
Make javaimp-maven work again
---
packages/javaimp/javaimp-gradle.el | 4 +++-
packages/javaimp/javaimp-maven.el | 4 +++-
packages/javaimp/javaimp-util.el | 10 ++++++----
packages/javaimp/javaimp.el | 41 ++++++++++++++++++++++++++------------
4 files changed, 40 insertions(+), 19 deletions(-)
diff --git a/packages/javaimp/javaimp-gradle.el
b/packages/javaimp/javaimp-gradle.el
index 2bf8e8e..ddbba87 100644
--- a/packages/javaimp/javaimp-gradle.el
+++ b/packages/javaimp/javaimp-gradle.el
@@ -23,7 +23,9 @@
(defcustom javaimp-gradle-program "gradle"
"Path to the `gradle' program. Customize it if the program is
-not on `exec-path'.")
+not on `exec-path'."
+ :group 'javaimp
+ :type 'string)
(defun javaimp--gradle-visit (file)
"Calls gradle on FILE to get various project information.
diff --git a/packages/javaimp/javaimp-maven.el
b/packages/javaimp/javaimp-maven.el
index ee63acb..9ceb1a9 100644
--- a/packages/javaimp/javaimp-maven.el
+++ b/packages/javaimp/javaimp-maven.el
@@ -26,7 +26,9 @@
(defcustom javaimp-mvn-program "mvn"
"Path to the `mvn' program. Customize it if the program is not
-on `exec-path'.")
+on `exec-path'."
+ :group 'javaimp
+ :type 'string)
(defun javaimp--maven-visit (file)
diff --git a/packages/javaimp/javaimp-util.el b/packages/javaimp/javaimp-util.el
index 67e9786..32af0ce 100644
--- a/packages/javaimp/javaimp-util.el
+++ b/packages/javaimp/javaimp-util.el
@@ -27,7 +27,9 @@
(defcustom javaimp-cygpath-program
(if (eq system-type 'cygwin) "cygpath")
"Path to the `cygpath' program (Cygwin only). Customize it if
-the program is not on `exec-path'.")
+the program is not on `exec-path'."
+ :group 'javaimp
+ :type 'string)
(defun javaimp--xml-children (xml-tree child-name)
@@ -88,18 +90,18 @@ unchanged."
(defun javaimp--call-build-tool (program handler &rest args)
"Runs PROGRAM with ARGS, then calls HANDLER in the temporary
buffer and returns its result"
- (message "Calling \"%s %s\" on args: %s" program target args)
+ (message "Calling %s on args: %s" program args)
(with-temp-buffer
(let ((status (let ((coding-system-for-read
(if (eq system-type 'cygwin) 'utf-8-dos)))
;; TODO check
in output on Gnu/Linux
- `(process-file ,program nil t nil ,@args)))
+ (apply #'process-file program nil t nil args)))
(buf (current-buffer)))
(with-current-buffer (get-buffer-create javaimp-debug-buf-name)
(erase-buffer)
(insert-buffer-substring buf))
(or (and (numberp status) (= status 0))
- (error "Build tool target \"%s\" failed with status \"%s\"" target
status))
+ (error "\"%s\" failed with status \"%s\"" program status))
(goto-char (point-min))
(funcall handler))))
diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el
index 29e3f2a..4f87c05 100644
--- a/packages/javaimp/javaimp.el
+++ b/packages/javaimp/javaimp.el
@@ -56,16 +56,14 @@
;; Example:
;;
;; (require 'javaimp)
-;;
;; (add-to-list 'javaimp-import-group-alist
;; '("\\`\\(my\\.company\\.\\|my\\.company2\\.\\)" . 80))
-;;
;; (setq javaimp-additional-source-dirs '("generated-sources/thrift"))
-;;
;; (add-hook 'java-mode-hook
;; (lambda ()
;; (local-set-key "\C-ci" 'javaimp-add-import)
;; (local-set-key "\C-co" 'javaimp-organize-imports)))
+;; (global-set-key (kbd "C-c j v") 'javaimp-visit-project)
;;
@@ -81,8 +79,6 @@
;; User options
-;; TODO add :type for defcustoms
-
(defgroup javaimp ()
"Add and reorder Java import statements in Maven/Gradle
projects"
@@ -97,16 +93,22 @@ where CLASSNAME-REGEXP is a regexp matching the fully
qualified
class name. Lowest-order groups are placed earlier.
The order of classes which were not matched is defined by
-`javaimp-import-default-order'.")
+`javaimp-import-default-order'."
+ :group 'javaimp
+ :type '(alist :key-type string :value-type integer))
(defcustom javaimp-import-default-order 50
"Defines the order of classes which were not matched by
-`javaimp-import-group-alist'")
+`javaimp-import-group-alist'"
+ :group 'javaimp
+ :type 'integer)
(defcustom javaimp-java-home (getenv "JAVA_HOME")
"Path to the JDK. Directory jre/lib underneath this path is
searched for JDK libraries. By default, it is initialized from
-the JAVA_HOME environment variable.")
+the JAVA_HOME environment variable."
+ :group 'javaimp
+ :type 'string)
(defcustom javaimp-additional-source-dirs nil
"List of directories where additional (e.g. generated)
@@ -123,17 +125,23 @@ becomes \"generated-sources/<plugin_name>\" (note the
absence
of the leading slash.
Custom values set in plugin configuration in pom.xml are not
-supported yet.")
+supported yet."
+ :group 'javaimp
+ :type '(repeat (string :tag "Relative directory")))
(defcustom javaimp-jar-program "jar"
"Path to the `jar' program used to read contents of jar files.
-Customize it if the program is not on `exec-path'.")
+Customize it if the program is not on `exec-path'."
+ :group 'javaimp
+ :type 'string)
(defcustom javaimp-include-current-module-classes t
"If non-nil, current module's classes are included into
completion alternatives. `javaimp-add-import' will find all java
files in the current project and add their fully-qualified names
-to the completion alternatives list.")
+to the completion alternatives list."
+ :group 'javaimp
+ :type 'boolean)
;; Variables and constants
@@ -178,7 +186,7 @@ directory containing pom.xml / build.gradle.kts.
After being processed by this command, the module tree becomes
known to javaimp and `javaimp-add-import' may be called inside
any module file."
- (interactive "DVisit Maven / Gradle project in directory: ")
+ (interactive "DVisit Maven or Gradle project in directory: ")
(let* ((exp-dir (expand-file-name (file-name-as-directory dir)))
build-file
(tree (cond
@@ -186,7 +194,8 @@ any module file."
(javaimp--maven-visit build-file))
((file-readable-p (setq build-file (concat exp-dir
"build.gradle.kts")))
(javaimp--gradle-visit build-file))
- (error "Could not find build file in dir %s" dir))))
+ (t
+ (error "Could not find build file in dir %s" dir)))))
(when tree
;; delete previous loaded tree, if any
(setq javaimp-project-forest
@@ -505,6 +514,12 @@ is `ordinary' or `static'. Interactively, NEW-IMPORTS is
nil."
(insert (format pattern (caar import)) ?\n)
(setq last-order order)))))
+(defun javaimp-reset()
+ "Forget all state"
+ (interactive)
+ (setq javaimp-project-forest nil)
+ (setq javaimp-cached-jars nil))
+
(provide 'javaimp)
;;; javaimp.el ends here