emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/javaimp 530dfd6: Use full module path for invoking Grad


From: Filipp Gunbin
Subject: [elpa] externals/javaimp 530dfd6: Use full module path for invoking Gradle task when reloading jars
Date: Thu, 28 Oct 2021 07:55:30 -0400 (EDT)

branch: externals/javaimp
commit 530dfd6e2a987a92741a607d39b918a5ac874a31
Author: Filipp Gunbin <fgunbin@fastmail.fm>
Commit: Filipp Gunbin <fgunbin@fastmail.fm>

    Use full module path for invoking Gradle task when reloading jars
---
 javaimp-gradle.el | 21 ++++++++++-----------
 javaimp-maven.el  |  2 +-
 javaimp-util.el   |  5 ++++-
 javaimp.el        | 29 +++++++++++++++++------------
 4 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/javaimp-gradle.el b/javaimp-gradle.el
index d7e3753..edc9107 100644
--- a/javaimp-gradle.el
+++ b/javaimp-gradle.el
@@ -27,9 +27,7 @@ Passes specially crafted init file as -I argument to gradle 
and
 invokes task contained in it.  This task outputs all needed
 information."
   (message "Visiting Gradle build file %s..." file)
-  (let* ((alists (javaimp--gradle-call file
-                                       #'javaimp--gradle-handler
-                                       "javaimpTask"))
+  (let* ((alists (javaimp--gradle-call file #'javaimp--gradle-handler))
          (modules (mapcar (lambda (alist)
                             (javaimp--gradle-module-from-alist alist file))
                           alists)))
@@ -108,19 +106,20 @@ descriptor."
                        :artifact artifact
                        :version (nth 2 parts)))))
 
-(defun javaimp--gradle-fetch-dep-jars-path (module)
-  ;; Always invoke on root file becase module's file may not exist,
-  ;; even if reported by Gradle as project.buildFile
+(defun javaimp--gradle-fetch-dep-jars-path (module ids)
   (javaimp--gradle-call
+   ;; Always invoke on orig file (which is root build script)
+   ;; because module's own file may not exist, even if reported by
+   ;; Gradle as project.buildFile
    (javaimp-module-file-orig module)
    (lambda ()
      (re-search-forward "^dep-jars=\\(.*\\)$")
      (match-string 1))
-   (concat (if (javaimp-module-parent-id module)
-               (concat ":" (javaimp-id-artifact (javaimp-module-id module))))
-           ":javaimpTask")))
+   (let ((mod-path (mapconcat #'javaimp-id-artifact (cdr ids) ":")))
+     (unless (string-empty-p mod-path)
+       (format ":%s:" mod-path)))))
 
-(defun javaimp--gradle-call (file handler task)
+(defun javaimp--gradle-call (file handler &optional mod-path)
   (let* ((local-gradlew (concat (file-name-directory file) "gradlew"))
          (gradlew (if (file-exists-p local-gradlew)
                       local-gradlew
@@ -137,6 +136,6 @@ descriptor."
      "-I" (javaimp-cygpath-convert-maybe
            (expand-file-name "javaimp-init-script.gradle"
                              javaimp--basedir))
-     task)))
+     (concat mod-path "javaimpTask"))))
 
 (provide 'javaimp-gradle)
diff --git a/javaimp-maven.el b/javaimp-maven.el
index 48b3a1b..87e4646 100644
--- a/javaimp-maven.el
+++ b/javaimp-maven.el
@@ -188,7 +188,7 @@ are somewhat arbitrary."
                 "pom.xml")
         modules)))))
 
-(defun javaimp--maven-fetch-dep-jars-path (module)
+(defun javaimp--maven-fetch-dep-jars-path (module _ids)
   (javaimp--call-build-tool
    javaimp-mvn-program
    (lambda ()
diff --git a/javaimp-util.el b/javaimp-util.el
index 5f1c2df..c87e811 100644
--- a/javaimp-util.el
+++ b/javaimp-util.el
@@ -65,10 +65,13 @@
   id parent-id
   file
   file-orig
-  final-name                           ;may be relative (to build-dir)
+  ;; Artifact final name, may be relative to build dir
+  final-name
   source-dirs build-dir
   dep-jars
   load-ts
+  ;; Function to retrieve DEP-JARS for MODULE, called with two
+  ;; arguments: MODULE and list of parent IDs
   dep-jars-path-fetcher
   raw                                   ;used only during parsing
   )
diff --git a/javaimp.el b/javaimp.el
index 4d9b01b..9dcb086 100644
--- a/javaimp.el
+++ b/javaimp.el
@@ -246,7 +246,7 @@ any module file."
 
 (defun javaimp--update-module-maybe (node)
   (let ((module (javaimp-node-contents node))
-       need-update)
+       need-update ids)
     ;; check if deps are initialized
     (unless (javaimp-module-dep-jars module)
       (message "Loading dependencies: %s" (javaimp-module-id module))
@@ -254,21 +254,26 @@ any module file."
     ;; check if this or any parent build file has changed since we
     ;; loaded the module
     (let ((tmp node))
-      (while (and tmp (not need-update))
+      (while tmp
        (let ((cur (javaimp-node-contents tmp)))
-         (when (> (max (if (file-exists-p (javaimp-module-file cur))
-                            (float-time (javaimp--get-file-ts 
(javaimp-module-file cur)))
-                          -1)
-                        (if (file-exists-p (javaimp-module-file-orig cur))
-                            (float-time (javaimp--get-file-ts 
(javaimp-module-file-orig cur)))
-                          -1))
-                  (float-time (javaimp-module-load-ts module)))
-           (message "Will reload dependencies for %s (some build-file changed)"
+         (when (and (not need-update)
+                     (> (max (if (file-exists-p (javaimp-module-file cur))
+                                 (float-time
+                                  (javaimp--get-file-ts (javaimp-module-file 
cur)))
+                               -1)
+                             (if (file-exists-p (javaimp-module-file-orig cur))
+                                 (float-time
+                                  (javaimp--get-file-ts 
(javaimp-module-file-orig cur)))
+                               -1))
+                       (float-time (javaimp-module-load-ts module))))
+           (message "Will reload dependencies for %s because build file 
changed"
                      (javaimp-module-id cur))
-           (setq need-update t)))
+           (setq need-update t))
+          (push (javaimp-module-id cur) ids))
        (setq tmp (javaimp-node-parent tmp))))
     (when need-update
-      (let* ((path (funcall (javaimp-module-dep-jars-path-fetcher module) 
module))
+      (let* ((path (funcall (javaimp-module-dep-jars-path-fetcher module)
+                            module ids))
              (new-dep-jars (javaimp--split-native-path path))
             (new-load-ts (current-time)))
        (setf (javaimp-module-dep-jars module) new-dep-jars)



reply via email to

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