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 2023/03/22 12:49:20 UTC

[maven] branch simplify created (now f58572acb)

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

elharo pushed a change to branch simplify
in repository https://gitbox.apache.org/repos/asf/maven.git


      at f58572acb remove unused branches in fake

This branch includes the following new commits:

     new f58572acb remove unused branches in fake

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] 01/01: remove unused branches in fake

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

elharo pushed a commit to branch simplify
in repository https://gitbox.apache.org/repos/asf/maven.git

commit f58572acb5087af4bf8a7e62f3621f774f2cf012
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Wed Mar 22 08:49:06 2023 -0400

    remove unused branches in fake
---
 .../maven/repository/TestRepositorySystem.java     | 127 +--------------------
 1 file changed, 4 insertions(+), 123 deletions(-)

diff --git a/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java b/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java
index efc929866..5b5590490 100644
--- a/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java
+++ b/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java
@@ -23,15 +23,8 @@ import javax.inject.Named;
 import javax.inject.Singleton;
 
 import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
 
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.api.model.Model;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DefaultArtifact;
 import org.apache.maven.artifact.InvalidRepositoryException;
@@ -43,17 +36,13 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.Repository;
 import org.apache.maven.model.io.ModelReader;
-import org.apache.maven.project.artifact.ArtifactWithDependencies;
 import org.apache.maven.settings.Mirror;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Server;
-import org.codehaus.plexus.util.StringUtils;
 import org.eclipse.aether.RepositorySystemSession;
 
 /**
@@ -63,14 +52,8 @@ import org.eclipse.aether.RepositorySystemSession;
 @Singleton
 public class TestRepositorySystem implements RepositorySystem {
 
-    private final ModelReader modelReader;
-
-    private final ArtifactFactory artifactFactory;
-
     @Inject
     public TestRepositorySystem(ModelReader modelReader, ArtifactFactory artifactFactory) {
-        this.modelReader = modelReader;
-        this.artifactFactory = artifactFactory;
     }
 
     public ArtifactRepository buildArtifactRepository(Repository repository) throws InvalidRepositoryException {
@@ -150,18 +133,7 @@ public class TestRepositorySystem implements RepositorySystem {
     }
 
     public Artifact createPluginArtifact(Plugin plugin) {
-        VersionRange versionRange;
-        try {
-            String version = plugin.getVersion();
-            if (StringUtils.isEmpty(version)) {
-                version = "RELEASE";
-            }
-            versionRange = VersionRange.createFromVersionSpec(version);
-        } catch (InvalidVersionSpecificationException e) {
-            return null;
-        }
-
-        return artifactFactory.createPluginArtifact(plugin.getGroupId(), plugin.getArtifactId(), versionRange);
+        throw new UnsupportedOperationException();
     }
 
     public Artifact createProjectArtifact(String groupId, String artifactId, String version) {
@@ -183,109 +155,18 @@ public class TestRepositorySystem implements RepositorySystem {
     public void injectProxy(List<ArtifactRepository> repositories, List<Proxy> proxies) {}
 
     public void publish(
-            ArtifactRepository repository, File source, String remotePath, ArtifactTransferListener transferListener)
-            throws ArtifactTransferFailedException {
-        // TODO Auto-generated method stub
-
+            ArtifactRepository repository, File source, String remotePath, ArtifactTransferListener transferListener {
     }
 
     public ArtifactResolutionResult resolve(ArtifactResolutionRequest request) {
-        ArtifactResolutionResult result = new ArtifactResolutionResult();
-
-        if (request.isResolveRoot()) {
-            try {
-                resolve(request.getArtifact(), request);
-                result.addArtifact(request.getArtifact());
-            } catch (IOException e) {
-                result.addMissingArtifact(request.getArtifact());
-            }
-        }
-
-        if (request.isResolveTransitively()) {
-            Map<String, Artifact> artifacts = new LinkedHashMap<>();
-
-            if (request.getArtifactDependencies() != null) {
-                for (Artifact artifact : request.getArtifactDependencies()) {
-                    artifacts.put(artifact.getDependencyConflictId(), artifact);
-                }
-            }
-
-            List<Dependency> dependencies = new ArrayList<>();
-            if (request.getArtifact() instanceof ArtifactWithDependencies) {
-                dependencies = ((ArtifactWithDependencies) request.getArtifact()).getDependencies();
-            } else {
-                Artifact pomArtifact = createProjectArtifact(
-                        request.getArtifact().getGroupId(),
-                        request.getArtifact().getArtifactId(),
-                        request.getArtifact().getVersion());
-                File pomFile = new File(
-                        request.getLocalRepository().getBasedir(),
-                        request.getLocalRepository().pathOf(pomArtifact));
-
-                try {
-                    Model model = modelReader.read(pomFile, null).getDelegate();
-
-                    dependencies = model.getDependencies().stream()
-                            .map(Dependency::new)
-                            .collect(Collectors.toList());
-                } catch (IOException e) {
-                    // ignore
-                }
-            }
-
-            for (Dependency dependency : dependencies) {
-                Artifact artifact = createDependencyArtifact(dependency);
-                if (!artifacts.containsKey(artifact.getDependencyConflictId())) {
-                    artifacts.put(artifact.getDependencyConflictId(), artifact);
-                }
-            }
-
-            for (Artifact artifact : artifacts.values()) {
-                try {
-                    resolve(artifact, request);
-                    result.addArtifact(artifact);
-                } catch (IOException e) {
-                    result.addMissingArtifact(artifact);
-                }
-            }
-        }
-
-        return result;
-    }
-
-    private void resolve(Artifact artifact, ArtifactResolutionRequest request) throws IOException {
-        if (Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
-            return;
-        }
-
-        ArtifactRepository localRepo = request.getLocalRepository();
-
-        File localFile = new File(localRepo.getBasedir(), localRepo.pathOf(artifact));
-
-        artifact.setFile(localFile);
-
-        if (!localFile.exists()) {
-            if (request.getRemoteRepositories().isEmpty()) {
-                throw new IOException(localFile + " does not exist and no remote repositories are configured");
-            }
-
-            ArtifactRepository remoteRepo = request.getRemoteRepositories().get(0);
-
-            File remoteFile = new File(remoteRepo.getBasedir(), remoteRepo.pathOf(artifact));
-
-            FileUtils.copyFile(remoteFile, localFile);
-        }
-
-        artifact.setResolved(true);
+        throw new UnsupportedOperationException();
     }
 
     public void retrieve(
             ArtifactRepository repository,
             File destination,
             String remotePath,
-            ArtifactTransferListener transferListener)
-            throws ArtifactTransferFailedException, ArtifactDoesNotExistException {
-        // TODO Auto-generated method stub
+            ArtifactTransferListener transferListener) {
 
     }