cstamas commented on code in PR #1610:
URL: https://github.com/apache/maven-resolver/pull/1610#discussion_r2401319455


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/GAVNameMapper.java:
##########
@@ -103,18 +104,46 @@ private static String getArtifactName(Artifact artifact, 
String prefix, String s
                 + suffix;
     }
 
+    private static final String MAVEN_METADATA = "maven-metadata.xml";
+
     private static String getMetadataName(Metadata metadata, String prefix, 
String separator, String suffix) {
-        String name = prefix;
-        if (!metadata.getGroupId().isEmpty()) {
-            name += metadata.getGroupId();
-            if (!metadata.getArtifactId().isEmpty()) {
-                name += separator + metadata.getArtifactId();
-                if (!metadata.getVersion().isEmpty()) {
-                    name += separator + metadata.getVersion();
+        if (metadata.getType().contains("/")) {
+            String metadataType = metadata.getType();
+            int slash = metadataType.indexOf('/');
+            return metadataType.substring(0, slash)

Review Comment:
   This needs a bit of history.... originally Maven had no means to (re)use 
Resolver transport to fetch (or put) non "standard" (not on layout) resources, 
and similarly, you could not reuse cache/checksum policies to perform such a 
transport, youd need to redo everything. As everything was either artifact or 
maven metadata. But with latest Resolver, metadata URI is calculated like this:
   
   Metadata is G, A, V and T. Remote URI is constructed as:
   * remote repository `baseUrl`
   * if G given, `+G.replaceAll(".", "/")` -- as artifact groupId
   * if A given, `+A` -- as artifact artifactId
   * if V given, `+V` -- as artifact version
   * `+type`
   
   Type was always "maven-metadata.xml". This is how you can make Resolver 
download the Maven Repository Metadata from G (plugin) level, GA (versions) 
level, and GAV (snapshot resolution) level.
   
   Later, we realized that type does not have to be always 
"maven-metadata.xml", but can be something else, so for example Archetype 
Catalog (that sits in [repo 
root](https://repo.maven.apache.org/maven2/archetype-catalog.xml)) can be 
addressed (and hence, use same transport to get artifacts) as this (this is how 
it is done in m-archetype-p to get and cache the catalog):
   
   `Metadata(G:"", A:"", V:"", Type:"archetype-catalog.xml")` and is cached 
locally as `archetype-catalog-$repoID.xml` (w/ checksums) by Resolver 
automatically (this is how "metadata" is handled by resolver).
   
   The subsequent step was to make `Metadata` be able to address **any (out of 
layout) file** on remote repository, or, in other words, make Maven able to get 
any file (and cache it, with all the whistle and bells of 
caching/policies/checksums) that are not addressable by GAV/artifact. This 
change was done in https://github.com/apache/maven-resolver/pull/1491 and it 
was needed for prefixes (again, to use same transport and all features of local 
repo like checksum validation/cache retention/etc and maven metadata tracking 
by origin). Basically prefix files lie on this path:
   
   `Metadata(G:"", A:"", V:"", Type:".meta/prefixes.txt")` and is cached 
locally as `.meta/prefixes-$repoId.txt` (w/ checksums) by resolver 
automatically.
   
   And currently, they are the ONLY Metadata files (in resolver and/or maven) 
that contain `/` (slash).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to