You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2025/12/13 17:39:08 UTC
[PR] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
elharo opened a new pull request, #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133
(no comment)
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616522946
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,41 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
+
+ // Limit resolution to ONLY the target remote repository
+ artifactRequest.setRepositories(Collections.singletonList(aetherRemoteRepository));
Review Comment:
Note: method receives a list of (bare) remote reposes and returns a list of remote reposes ready to be used. The arity of input param and returned list is not same (ie. you may have `mirrorOf:*` in your settings, and that would mean that no matter how many bare reposes you pass in, you get that one mirror "of all" as output).
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616515004
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
If I can avoid downloading the file, great. I'll try. I think -- I could be wrong and tell me if I am -- that if I set a file on artifact, then the check of the remote repository might not happen at all, which I don't think is what we want here.
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2617208801
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
RepositoryConnectorProvider is public, so I call it fair game.
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616522946
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,41 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
+
+ // Limit resolution to ONLY the target remote repository
+ artifactRequest.setRepositories(Collections.singletonList(aetherRemoteRepository));
Review Comment:
Note: method receives a list of (bare) remote reposes and returns a list. The arity of input param and returned list is not same (ie. you may have `mirrorOf:*` in your settings, and that would mean that no matter how many bare reposes you pass in, you get that one mirror "of all" as output).
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616529835
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
Hm, let's go with plain resolving for now.... To get all features, you'd need https://github.com/apache/maven-resolver/blob/master/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/RepositoryConnectorProvider.java which is in impl package (impl module of resolver)...
So, let's do baby steps for now, and go for plain resolve for now?
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616521237
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
In face, this is how we ensure "transitioning" for Maven3 plugins between Maven 3.9 and 4 (that still must execute Maven 3 plugins). Just stay away from deprecated APIs (and non public internals) in Maven3/Resolver1 and you are fine in Maven4/Resolver2.
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
In fact, this is how we ensure "transitioning" for Maven3 plugins between Maven 3.9 and 4 (that still must execute Maven 3 plugins). Just stay away from deprecated APIs (and non public internals) in Maven3/Resolver1 and you are fine in Maven4/Resolver2.
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616516727
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
also, I'm not sure I can do the existence check only approach without depending on the SPI. Are we OK with that? I think I am, but I fall into the "Everything visible is public and calling something an SPI or internal or experimental is wishful thinking" camp. :-)
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616522946
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,41 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
+
+ // Limit resolution to ONLY the target remote repository
+ artifactRequest.setRepositories(Collections.singletonList(aetherRemoteRepository));
Review Comment:
Note: method receives a list of (bare) remote reposes and returns a list of remote reposes ready to be used. The ~arity~ numberosity (?) of input param and returned list is not same (ie. you may have `mirrorOf:*` in your settings, and that would mean that no matter how many bare reposes you pass in, you get that one mirror "of all" as output).
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,41 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
+
+ // Limit resolution to ONLY the target remote repository
+ artifactRequest.setRepositories(Collections.singletonList(aetherRemoteRepository));
Review Comment:
Note: method receives a list of (bare) remote reposes and returns a list of remote reposes ready to be used. The ~arity~ numerosity (?) of input param and returned list is not same (ie. you may have `mirrorOf:*` in your settings, and that would mean that no matter how many bare reposes you pass in, you get that one mirror "of all" as output).
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616521237
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
In fact, this is how we ensure "transitioning" for Maven3 plugins between Maven 3.9 and 4 (that still must execute Maven 3 plugins but uses Resolver 2). Just stay away from deprecated APIs in Maven3/Resolver1 (and non public internals) and you are fine in Maven4/Resolver2.
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616521237
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
In fact, this is how we ensure "transitioning" for Maven3 plugins between Maven 3.9 and 4 (that still must execute Maven 3 plugins but uses Resolver 2). Just stay away from deprecated APIs (and non public internals) in Maven3/Resolver1 and you are fine in Maven4/Resolver2.
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616522946
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,41 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
+
+ // Limit resolution to ONLY the target remote repository
+ artifactRequest.setRepositories(Collections.singletonList(aetherRemoteRepository));
Review Comment:
Note: method receives a list of (bare) remote reposes and returns a list of remote reposes ready to be used. The ~arity~ numerosity (?) of input param and returned list ~is~ may not be the same (ie. you may have `mirrorOf:*` in your settings, and that would mean that no matter how many bare reposes you pass in, you get that one mirror "of all" as output).
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616521237
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
In fact, this is how we ensure "transitioning" for Maven3 plugins between Maven 3.9 and 4 (that still must execute Maven 3 plugins but uses Resolver 2). Just stay away from deprecated APIs in Maven3/Resolver 1 (and non public internals) in Maven3/Resolver1 and you are fine in Maven4/Resolver2.
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616516045
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
Yes, depending on repo policy, which for central is never as release artifacts are immutable (once they are here, no change to them is expected).
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616468083
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
If you set file on artifact, Resolver will perform "existence check" only on remote:
https://github.com/apache/maven-resolver/blob/5b46366f8bfcb8cb40f935907648f7c41141d472/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java#L526-L537
So hint, maybe use LRM to lookup (if it is present locally) and set it here?
Unsure about the use case, but resolving will download the whole artifact. If really interested in "remote existence" only, you may go deeper and use connector to issue targeted existence check `ArtifactDownload` requests instead.
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo merged PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616512126
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,41 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
+
+ // Limit resolution to ONLY the target remote repository
+ artifactRequest.setRepositories(Collections.singletonList(aetherRemoteRepository));
Review Comment:
To equip bare remote repo (created above) with auth/proxy, you need to "dip" it thru this method:
https://github.com/apache/maven-resolver/blob/maven-resolver-1.9.x/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java#L240-L259
Returned collection will have proxy/auth/mirrors applied.
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616519783
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
Review Comment:
https://maven.apache.org/resolver-archives/resolver-1.9.24/api-compatibility.html
the modules api, util and spi are "public" and in fact are binary compatible even between Resolver 1.9.x and 2.x.
--
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] Use Maven Resolver intead of HTTP components [maven-doap-plugin]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #133:
URL: https://github.com/apache/maven-doap-plugin/pull/133#discussion_r2616437248
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -162,6 +170,9 @@ public class DoapMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
Review Comment:
The newly added repositorySystemSession parameter is missing Javadoc documentation. Similar parameters in this class (like the 'project' parameter above) include a comment block describing the parameter's purpose. Adding documentation would improve code maintainability and help developers understand this parameter's role in the Mojo.
```suggestion
/**
* The current repository system session, which is used for artifact resolution
* and other repository-related operations during the execution of this Mojo.
*/
```
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
+
+ ArtifactRequest artifactRequest = new ArtifactRequest();
+ artifactRequest.setArtifact(aetherArtifact);
+
+ // Limit resolution to ONLY the target remote repository
+ artifactRequest.setRepositories(Collections.singletonList(aetherRemoteRepository));
+
+ try {
+ // Attempt to resolve the artifact
+ ArtifactResult result = repositorySystem.resolveArtifact(repositorySystemSession, artifactRequest);
+
+ if (result.isResolved()) {
+ return true;
+ }
+
+ } catch (org.eclipse.aether.resolution.ArtifactResolutionException ex) {
+ return false;
+ }
+
+ return false;
+ }
+
/**
* Write all DOAP repositories.
*
Review Comment:
The return statement inside the try block at line 1426 makes the return statement at line 1433 redundant. Consider simplifying the logic by either removing the explicit check at line 1425 and directly returning the result of result.isResolved() before the catch block, or restructuring to avoid the unreachable return false at line 1433. The current structure suggests that result.isResolved() could be false, but in practice, if resolveArtifact succeeds without throwing an exception, the artifact should be resolved.
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -162,6 +170,9 @@ public class DoapMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
+ @Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
+ private RepositorySystemSession repositorySystemSession;
+
Review Comment:
This line contains trailing whitespace. Remove the trailing whitespace to maintain code cleanliness and consistency with project coding standards.
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
Review Comment:
The new private method isArtifactInRepository lacks Javadoc documentation. Given that this method performs a critical function (checking artifact availability in a repository using Maven Resolver), it should include documentation explaining its purpose, parameters, return value, and potentially the resolution strategy being used. This is especially important since the method replaces the previous HTTP-based checking mechanism.
```suggestion
/**
* Checks whether the specified Maven artifact is available in the given remote repository
* using the Maven Resolver (Aether).
* <p>
* This method converts the legacy Maven {@link Artifact} and {@link ArtifactRepository}
* to their Aether equivalents and attempts to resolve the artifact using only the specified
* remote repository. If the artifact can be resolved, it is considered present.
*
* @param artifact the Maven artifact to check for availability
* @param repository the remote repository to check for the artifact
* @return {@code true} if the artifact is found in the repository, {@code false} otherwise
*/
```
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -144,6 +149,9 @@ public class DoapMojo extends AbstractMojo {
@Inject
private RepositoryMetadataManager repositoryMetadataManager;
Review Comment:
The newly injected RepositorySystem component is missing Javadoc documentation. For consistency with the other injected components in this class (like repositoryMetadataManager above it), it should include a comment describing its purpose and a @since tag. This would make the codebase more maintainable and help other developers understand the component's role.
```suggestion
/**
* The repository system used for artifact resolution.
*
* @since 1.2
*/
```
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -144,6 +149,9 @@ public class DoapMojo extends AbstractMojo {
@Inject
private RepositoryMetadataManager repositoryMetadataManager;
+ @Inject
+ private RepositorySystem repositorySystem;
+
Review Comment:
This line contains trailing whitespace. Remove the trailing whitespace to maintain code cleanliness and consistency with project coding standards.
##########
src/main/java/org/apache/maven/plugin/doap/DoapMojo.java:
##########
@@ -1381,6 +1392,42 @@ private void writeReleases(XMLWriter writer, MavenProject project) throws MojoEx
}
}
+ private boolean isArtifactInRepository(Artifact artifact, ArtifactRepository repository) {
+ // Convert Legacy Artifact to Aether Artifact
+ String artifactCoordinates = String.format(
+ "%s:%s:%s:%s",
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
+
+ org.eclipse.aether.artifact.Artifact aetherArtifact =
+ new org.eclipse.aether.artifact.DefaultArtifact(artifactCoordinates);
+
+ // Convert Legacy ArtifactRepository to Aether RemoteRepository
+ // TODO: do we need to handle authentication/proxies here?
+ RemoteRepository aetherRemoteRepository = new RemoteRepository.Builder(
+ repository.getId(), repository.getLayout().getId(), repository.getUrl())
+ .build();
Review Comment:
The TODO comment about handling authentication/proxies should be addressed before merging. The old code using DoapUtil.fetchURL likely handled these concerns through Maven's settings. Since you're now using Maven Resolver directly, you should either implement proper authentication/proxy handling or document why it's not needed. The repositorySystemSession parameter likely already contains this configuration, but it should be verified that the RemoteRepository.Builder properly inherits these settings or explicitly configures them.
```suggestion
// Handle authentication/proxies using RepositorySystemSession selectors
RemoteRepository.Builder repoBuilder = new RemoteRepository.Builder(
repository.getId(), repository.getLayout().getId(), repository.getUrl());
// Apply authentication if available
if (repositorySystemSession != null) {
org.eclipse.aether.repository.Authentication authentication =
repositorySystemSession.getAuthenticationSelector().getAuthentication(repoBuilder.build());
if (authentication != null) {
repoBuilder.setAuthentication(authentication);
}
org.eclipse.aether.repository.Proxy proxy =
repositorySystemSession.getProxySelector().getProxy(repoBuilder.build());
if (proxy != null) {
repoBuilder.setProxy(proxy);
}
}
RemoteRepository aetherRemoteRepository = repoBuilder.build();
```
--
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