This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 8db0af6c0f GROOVY-8162: Update Groovysh to JLine3 (improved grape 
completion)
8db0af6c0f is described below

commit 8db0af6c0fe77bd16de4c7b95945bda08ac93ff7
Author: Paul King <[email protected]>
AuthorDate: Wed Aug 13 17:14:56 2025 +1000

    GROOVY-8162: Update Groovysh to JLine3 (improved grape completion)
---
 .../groovysh/jline/MavenCoordinateCompleter.groovy | 36 +++++++++++++++++-----
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git 
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/MavenCoordinateCompleter.groovy
 
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/MavenCoordinateCompleter.groovy
index f25dde947c..a6832122bd 100644
--- 
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/MavenCoordinateCompleter.groovy
+++ 
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/MavenCoordinateCompleter.groovy
@@ -90,10 +90,19 @@ class MavenCoordinateCompleter implements Completer {
 
     private void suggestArtifactIds(String groupId, String artifactPrefix, 
List<Candidate> candidates) {
         def groupDir = new File(mavenRepo, groupId.replace('.', 
File.separator))
-        if (!groupDir.exists()) return
+        if (groupDir.exists()) {
+            groupDir.eachDir { artifactDir ->
+                if (artifactDir.name.startsWith(artifactPrefix) && 
isVersionDirPresent(artifactDir)) {
+                    def suggestion = "${groupId}:${artifactDir.name}:"
+                    candidates << new Candidate(suggestion, suggestion, null, 
null, '', null, false)
+                }
+            }
+        }
 
+        groupDir = new File(grapeRepo, groupId)
+        if (!groupDir.exists()) return
         groupDir.eachDir { artifactDir ->
-            if (artifactDir.name.startsWith(artifactPrefix) && 
isVersionDirPresent(artifactDir)) {
+            if (artifactDir.name.startsWith(artifactPrefix) && 
isJarsDirPresent(artifactDir)) {
                 def suggestion = "${groupId}:${artifactDir.name}:"
                 candidates << new Candidate(suggestion, suggestion, null, 
null, '', null, false)
             }
@@ -101,12 +110,21 @@ class MavenCoordinateCompleter implements Completer {
     }
 
     private void suggestVersions(String groupId, String artifactId, String 
versionPrefix, List<Candidate> candidates) {
-        def artifactDir = new File(mavenRepo, "${groupId.replace('.', 
File.separator)}/${artifactId}")
-        if (!artifactDir.exists()) return
+        def artifactDir = new File(mavenRepo, "${groupId.replace('.', 
File.separator)}${File.separator}${artifactId}")
+        if (artifactDir.exists()) {
+            artifactDir.eachDir { versionDir ->
+                if (versionDir.name.startsWith(versionPrefix)) {
+                    def suggestion = 
"${groupId}:${artifactId}:${versionDir.name}"
+                    candidates << new Candidate(suggestion, suggestion, null, 
null, ' ', null, true)
+                }
+            }
+        }
 
-        artifactDir.eachDir { versionDir ->
-            if (versionDir.name.startsWith(versionPrefix)) {
-                def suggestion = "${groupId}:${artifactId}:${versionDir.name}"
+        artifactDir = new File(grapeRepo, 
"${groupId}${File.separator}${artifactId}${File.separator}jars")
+        if (!artifactDir.exists()) return
+        artifactDir.eachFile { candidate ->
+            if (candidate.name.startsWith("$artifactId-$versionPrefix") && 
candidate.name.endsWith('.jar')) {
+                def suggestion = /$groupId:$artifactId:${(candidate.name - 
'.jar') - "$artifactId-"}/
                 candidates << new Candidate(suggestion, suggestion, null, 
null, ' ', null, true)
             }
         }
@@ -116,6 +134,10 @@ class MavenCoordinateCompleter implements Completer {
         dir.isDirectory() && dir.listFiles()?.any { isVersionDir(it) }
     }
 
+    private boolean isJarsDirPresent(File dir) {
+        dir.isDirectory() && dir.listFiles()?.any { it.name == 'jars' }
+    }
+
     private boolean isVersionDir(File dir) {
         dir.isDirectory() && dir.name ==~ /^\d+(\.\d+)*([-_.].*)?$/
     }

Reply via email to