You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "cstamas (via GitHub)" <gi...@apache.org> on 2025/10/01 09:28:14 UTC
[PR] GH-1609 Bad metadata naming cause name colllaps [maven-resolver]
cstamas opened a new pull request, #1610:
URL: https://github.com/apache/maven-resolver/pull/1610
And hence, congestion with possible timeouts on resource. In case of metadata, `Metadata#getType` was totally ignored, which turns out was wrong, as today we have more types than the simple `maven-metadata.xml`.
Fixes #1609
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #1610:
URL: https://github.com/apache/maven-resolver/pull/1610#discussion_r2401351933
##########
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:
And to answer your original question "we put the first part of the metadata in front"... due local repository layout. If I ask from Central following metadata:
* `Metadata(G:"", A:"", V:"", Type:"prefixes.txt")`
* `Metadata(G:"", A:"", V:"", Type:".meta/prefixes.txt")`
* `Metadata(G:"", A:"", V:"", Type:".meta/meta/prefixes.txt")`
They would call conflict, as Resolver handles Metadata file names in local repository by appending origin repoId, so they would be locally then be named `prefix-$repoId.txt` and clash.
Oh, but you are right, these are local repo paths, and we talk about _lock names_. Yes, you are right, we could replace `/` to `_` or anything to keep them "flat", agreed.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
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 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. Path 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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
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. Path 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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #1610:
URL: https://github.com/apache/maven-resolver/pull/1610#discussion_r2401255984
##########
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)
+ + separator
+ + getMetadataName(
+ new DefaultMetadata(
Review Comment:
It looks inefficient to create an object just to call the method recursively. It may be cleaner to define a new method which would have the individual parameters.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #1610:
URL: https://github.com/apache/maven-resolver/pull/1610#discussion_r2401344061
##########
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:
One of the typical pain was long time index: indexer are also _published within repository_, [here](https://repo.maven.apache.org/maven2/.index/). And originally, Maven Indexer had to reimplement everything (full transport stack) to get it from same place, from where user was already getting artifacts from (with same possible proxies, mirrors, auth and all the cruft). Now, Resolver would be able even to get indexes for you, no need to reimplement anything, as any file, that is published via repository is reachable to Resolver and Maven (and plugins).
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
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. Path 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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #1610:
URL: https://github.com/apache/maven-resolver/pull/1610#discussion_r2401344061
##########
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:
One of the typical pain was long time index: indexes are also _published within repository_, [here](https://repo.maven.apache.org/maven2/.index/). And originally, Maven Indexer had to reimplement everything (full transport stack) to get it from same place, from where user was already getting artifacts from (with same possible proxies, mirrors, auth and all the cruft). Now, Resolver would be able even to get indexes for you, no need to reimplement anything, as any file, that is published via repository is reachable to Resolver and Maven (and plugins).
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas merged PR #1610:
URL: https://github.com/apache/maven-resolver/pull/1610
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #1610:
URL: https://github.com/apache/maven-resolver/pull/1610#discussion_r2401261240
##########
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:
Why do we put the first part of the metadata in front while we usually used `g/a/v/t` ?
What are the types containing a `/` ?
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
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).
The point is, that archetype catalog, but also prefixes _are repository metadata resources_, and they need same checksum validation, cache retention as any other "metadata". And what happens is total reuse of all existing functionality of Resolver to get/cache these files (so `-U` also updates them, etc).
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-1609 Bad metadata naming [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
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).
The point is, that archetype catalog, but also prefixes _are repository metadata resources_, and they need same checksum validation, cache retention as any other "metadata". And what happens is total reuse of all existing functionality of Resolver to get/cache these files.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org