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

jdaugherty pushed a commit to branch wrapper-rewrite
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit ed517397e4c11c5a66d2cfa9e2a128e9b6cfb14f
Author: James Daugherty <jdaughe...@jdresources.net>
AuthorDate: Wed May 14 00:49:48 2025 -0400

    Fix file handling for maven paths
---
 .../grails/cli/profile/ProfileRepoConfig.groovy    | 25 +++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git 
a/grails-shell-cli/src/main/groovy/org/grails/cli/profile/ProfileRepoConfig.groovy
 
b/grails-shell-cli/src/main/groovy/org/grails/cli/profile/ProfileRepoConfig.groovy
index 36a5708456..543dfea68b 100644
--- 
a/grails-shell-cli/src/main/groovy/org/grails/cli/profile/ProfileRepoConfig.groovy
+++ 
b/grails-shell-cli/src/main/groovy/org/grails/cli/profile/ProfileRepoConfig.groovy
@@ -20,6 +20,8 @@ import grails.util.BuildSettings
 import grails.util.Environment
 import org.grails.cli.GrailsCli
 
+import java.nio.file.Paths
+
 class ProfileRepoConfig {
     String name
     String url
@@ -37,13 +39,13 @@ class ProfileRepoConfig {
             for (repoName in profileRepos.keySet()) {
                 def data = profileRepos.get(repoName)
                 if (data instanceof Map) {
-                    def uri = data.get("url")
+                    String uri = data.get("url") as String
                     def snapshots = data.get('snapshotsEnabled')
                     if (uri != null) {
                         boolean enableSnapshots = snapshots != null ? 
Boolean.valueOf(snapshots.toString()) : false
                         final String username = data.get('username') as String
                         final String password = data.get('password') as String
-                        repos << new ProfileRepoConfig(name: repoName as 
String, url: uri as String, snapshots: enableSnapshots, username: username as 
String, password: password as String)
+                        repos << new ProfileRepoConfig(name: repoName as 
String, url: uri, snapshots: enableSnapshots, username: username as String, 
password: password as String)
                     }
                 }
             }
@@ -52,9 +54,26 @@ class ProfileRepoConfig {
         // If the repo url from the wrapper is set, then the wrapper has been 
configured for a local install, so honor it as a valid source
         String repoUrl = System.getProperty("grails.repo.url") ?: 
System.getenv('GRAILS_REPO_URL')
         if (repoUrl) {
-            repos << new ProfileRepoConfig(name: "grails-override-repo", url: 
repoUrl, snapshots: Environment.grailsVersion.endsWith("SNAPSHOT"))
+            repos << new ProfileRepoConfig(name: "grails-override-repo", url: 
fixRepoUrl(repoUrl), snapshots: Environment.grailsVersion.endsWith("SNAPSHOT"))
         }
 
         repos
     }
+
+    private static String fixRepoUrl(String repoUrl) {
+        try {
+            URI uri = new URI(repoUrl)
+            if (uri.getScheme() != null) {
+                return repoUrl
+            }
+        } catch (URISyntaxException e) {
+            // Not a valid URI, fall through to file conversion
+        }
+
+        if (repoUrl.startsWith('http')) {
+            return repoUrl
+        }
+
+        Paths.get(repoUrl).toUri().toString()
+    }
 }

Reply via email to