[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] scratch/javaimp-gradle 341ceaf 2/2: Make gradle work

From: Filipp Gunbin
Subject: [elpa] scratch/javaimp-gradle 341ceaf 2/2: Make gradle work
Date: Thu, 24 Oct 2019 07:56:49 -0400 (EDT)

branch: scratch/javaimp-gradle
commit 341ceaf79c0d05fa9cb336079a476da16f6638c1
Author: Filipp Gunbin <address@hidden>
Commit: Filipp Gunbin <address@hidden>

    Make gradle work
 packages/javaimp/javaimp-gradle.el | 32 ++++++++++++++++----------------
 packages/javaimp/javaimp-util.el   |  7 ++++---
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/packages/javaimp/javaimp-gradle.el 
index ddbba87..d2b8374 100644
--- a/packages/javaimp/javaimp-gradle.el
+++ b/packages/javaimp/javaimp-gradle.el
@@ -45,18 +45,18 @@ information."
         ;; first module is always root
-        (javaimp--build-tree (car modules) nil modules))
-    (message "Loaded tree for %s" file)))
+        (javaimp--build-tree (car modules) nil modules)
+      (message "Loaded tree for %s" file))))
 (defun javaimp--gradle-handler ()
   (goto-char (point-min))
-  (let (modules alist pair sym val)
+  (let (modules alist parts sym val)
     (while (not (eobp))
-      (setq pair (split-string (thing-at-point 'line) "="))
-      (unless (= (length pair) 2)
-        (error "Invalid pair from gradle output: %s" pair))
-      (setq sym (intern (car pair))
-            val (cadr pair))
+      (setq parts (split-string (thing-at-point 'line) "[=\n]+"))
+      (setq sym (intern (or (nth 0 parts)
+                            (error "Invalid line in gradle output: %s"
+                                   (thing-at-point 'line))))
+            val (nth 1 parts))
       (when (and (eq sym 'id) alist)    ;start of next module
         (push (javaimp--gradle-module-from-alist alist) modules)
         (setq alist nil))
@@ -68,21 +68,21 @@ information."
 (defun javaimp--gradle-module-from-alist (alist)
-   :id (javaimp--gradle-id-from-colon-separated (cadr (assq 'id alist)))
-   :parent-id (javaimp--gradle-id-from-colon-separated (cadr (assq 'parent-id 
-   :file (cadr (assq 'file alist))
-   :final-name (cadr (assq 'final-name alist))
+   :id (javaimp--gradle-id-from-colon-separated (cdr (assq 'id alist)))
+   :parent-id (javaimp--gradle-id-from-colon-separated (cdr (assq 'parent-id 
+   :file (cdr (assq 'file alist))
+   :final-name (cdr (assq 'final-name alist))
    :packaging "jar"                     ;TODO
    :source-dir (file-name-as-directory
-                 (cadr (assq 'source-dir alist))))
+                 (cdr (assq 'source-dir alist))))
    :test-source-dir (file-name-as-directory
-                      (cadr (assq 'test-source-dir alist))))
+                      (cdr (assq 'test-source-dir alist))))
    :build-dir (file-name-as-directory
-                (cadr (assq 'build-dir alist))))
-   :dep-jars (javaimp--split-native-path (cadr (assq 'dep-jars alist)))
+                (cdr (assq 'build-dir alist))))
+   :dep-jars (javaimp--split-native-path (cdr (assq 'dep-jars alist)))
    :load-ts (current-time)
    :dep-jars-path-fetcher #'javaimp--gradle-fetch-dep-jars-path))
diff --git a/packages/javaimp/javaimp-util.el b/packages/javaimp/javaimp-util.el
index 32af0ce..dae6907 100644
--- a/packages/javaimp/javaimp-util.el
+++ b/packages/javaimp/javaimp-util.el
@@ -106,9 +106,10 @@ buffer and returns its result"
       (funcall handler))))
 (defun javaimp--split-native-path (path)
-  (let ((converted (javaimp-cygpath-convert-maybe path 'unix t))
-       (sep-regex (concat "[" path-separator "\n" "]+")))
-    (split-string converted sep-regex t)))
+  (when path
+    (let ((converted (javaimp-cygpath-convert-maybe path 'unix t))
+         (sep-regex (concat "[" path-separator "\n" "]+")))
+      (split-string converted sep-regex))))
 (defun javaimp--build-tree (this parent-node all)
   (message "Building tree for module: %s" (javaimp-module-id this))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]