Added Gradle support.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 27 Aug 2017 23:12:42 +0300
changeset 1535 15388800a8e2
parent 1534 a20f8f4abec7
child 1536 5854fc2dbece
Added Gradle support.
maven-central.el
--- a/maven-central.el	Mon Jul 31 17:43:35 2017 +0300
+++ b/maven-central.el	Sun Aug 27 23:12:42 2017 +0300
@@ -115,6 +115,37 @@
       (maven-central/versions groupId artifactId))
     ))
 
+(defun maven-central/parse-gradle-dependency ()
+  (let ( groupId artifactId )
+    (save-excursion
+      (goto-char (line-beginning-position))
+      (when (re-search-forward "\\([\"']\\)\\([a-zA-Z0-9.-]+\\):\\([a-zA-Z0-9.-]+\\):?[a-zA-Z0-9.-]*\\1" (line-end-position) t)
+        (setq groupId (match-string 2))
+        (setq artifactId (match-string 3))
+        (list groupId artifactId)))))
+
+;;;###autoload
+(defun maven-central-last-version-from-gradle ()
+  (interactive)
+  (let (dependency groupId artifactId)
+    (setq dependency (maven-central/parse-gradle-dependency))
+    (setq groupId (elt dependency 0))
+    (setq artifactId (elt dependency 1))
+    (when (and groupId artifactId)
+      (maven-central/last-version groupId artifactId))
+    ))
+
+;;;###autoload
+(defun maven-central-versions-from-gradle ()
+  (interactive)
+  (let (dependency groupId artifactId)
+    (setq dependency (maven-central/parse-gradle-dependency))
+    (setq groupId (elt dependency 0))
+    (setq artifactId (elt dependency 1))
+    (when (and groupId artifactId)
+      (maven-central/versions groupId artifactId))
+    ))
+
 ;; (maven-central/last-version "junit" "junit")
 
 (provide 'maven-central)