You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2025/12/13 17:38:26 UTC

(maven-doap-plugin) branch art created (now fcb0452)

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

elharo pushed a change to branch art
in repository https://gitbox.apache.org/repos/asf/maven-doap-plugin.git


      at fcb0452  wip

This branch includes the following new commits:

     new fcb0452  wip

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(maven-doap-plugin) 01/01: wip

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch art
in repository https://gitbox.apache.org/repos/asf/maven-doap-plugin.git

commit fcb045290e298a2963129df2de113711690e3a12
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sat Dec 13 12:38:19 2025 -0500

    wip
---
 .../org/apache/maven/plugin/doap/DoapMojo.java     | 60 ++++++++++++++++++++--
 1 file changed, 56 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java b/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java
index a30e450..d7951ed 100644
--- a/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java
+++ b/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java
@@ -78,6 +78,11 @@ import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.WriterFactory;
 import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
 import org.codehaus.plexus.util.xml.XMLWriter;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResult;
 
 /**
  * <p>
@@ -144,6 +149,9 @@ public class DoapMojo extends AbstractMojo {
     @Inject
     private RepositoryMetadataManager repositoryMetadataManager;
 
+    @Inject
+    private RepositorySystem repositorySystem;
+    
     /**
      * Internationalization component.
      *
@@ -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;
+    
     /**
      * The name of the DOAP file that will be generated.
      */
@@ -1349,12 +1360,12 @@ public class DoapMojo extends AbstractMojo {
                 }
 
                 String fileRelease = repo.getUrl() + "/" + repo.pathOf(artifactRelease);
-                try {
-                    DoapUtil.fetchURL(settings, new URL(fileRelease));
-                } catch (IOException e) {
-                    getLog().debug("IOException :" + e.getMessage());
+                
+                if (!isArtifactInRepository(artifactRelease, repo)) {
+                    getLog().debug(artifactRelease + " is not in the repository " + repo);
                     continue;
                 }
+
                 DoapUtil.writeElement(writer, doapOptions.getXmlnsPrefix(), "file-release", fileRelease);
 
                 Date releaseDate = null;
@@ -1381,6 +1392,47 @@ public class DoapMojo extends AbstractMojo {
         }
     }
 
+    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.
      *