You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2025/06/16 14:56:02 UTC

(maven-resolver) branch master updated: Metadata type out of coordinates (#1491)

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

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git


The following commit(s) were added to refs/heads/master by this push:
     new a9573dd8 Metadata type out of coordinates (#1491)
a9573dd8 is described below

commit a9573dd8b0e8d16f771f1bb6183f034de2f723b7
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Mon Jun 16 16:55:56 2025 +0200

    Metadata type out of coordinates (#1491)
    
    Fix for metadata type that contains `/` (slash), as right now the layout get messed up in such cases. Originally, the "type" was filename, and GAV are the coordinates, but with this simple change, we can (re)use Resolver to resolve files that are not in "addressable space", but still have all the benefit of caching/auth etc.
---
 .../aether/internal/impl/DefaultLocalPathComposer.java | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalPathComposer.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalPathComposer.java
index a2a1d31e..e85a4c56 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalPathComposer.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalPathComposer.java
@@ -89,13 +89,19 @@ public final class DefaultLocalPathComposer implements LocalPathComposer {
     }
 
     private String insertRepositoryKey(String metadataType, String repositoryKey) {
-        String result;
-        int idx = metadataType.indexOf('.');
-        if (idx < 0) {
-            result = metadataType + '-' + repositoryKey;
+        if (metadataType.contains("/") && !metadataType.endsWith("/")) {
+            int lastSlash = metadataType.lastIndexOf('/');
+            return metadataType.substring(0, lastSlash + 1)
+                    + insertRepositoryKey(metadataType.substring(lastSlash + 1), repositoryKey);
         } else {
-            result = metadataType.substring(0, idx) + '-' + repositoryKey + metadataType.substring(idx);
+            String result;
+            int idx = metadataType.indexOf('.');
+            if (idx < 0) {
+                result = metadataType + '-' + repositoryKey;
+            } else {
+                result = metadataType.substring(0, idx) + '-' + repositoryKey + metadataType.substring(idx);
+            }
+            return result;
         }
-        return result;
     }
 }