Skip to content

Commit b758518

Browse files
authored
backport: Metadata type out of coordinates (#1491) (#1503)
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.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. This is a backport for #1491
1 parent 615eab3 commit b758518

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalPathComposer.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,19 @@ public String getPathForMetadata(Metadata metadata, String repositoryKey) {
8989
}
9090

9191
private String insertRepositoryKey(String metadataType, String repositoryKey) {
92-
String result;
93-
int idx = metadataType.indexOf('.');
94-
if (idx < 0) {
95-
result = metadataType + '-' + repositoryKey;
92+
if (metadataType.contains("/") && !metadataType.endsWith("/")) {
93+
int lastSlash = metadataType.lastIndexOf('/');
94+
return metadataType.substring(0, lastSlash + 1)
95+
+ insertRepositoryKey(metadataType.substring(lastSlash + 1), repositoryKey);
9696
} else {
97-
result = metadataType.substring(0, idx) + '-' + repositoryKey + metadataType.substring(idx);
97+
String result;
98+
int idx = metadataType.indexOf('.');
99+
if (idx < 0) {
100+
result = metadataType + '-' + repositoryKey;
101+
} else {
102+
result = metadataType.substring(0, idx) + '-' + repositoryKey + metadataType.substring(idx);
103+
}
104+
return result;
98105
}
99-
return result;
100106
}
101107
}

0 commit comments

Comments
 (0)