Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2013 Red Hat, Inc. and/or its affiliates.
   *
   * Licensed under the Eclipse Public License version 1.0, available at
   * http://www.eclipse.org/legal/epl-v10.html
   */
  
  package org.jboss.forge.arquillian.maven;
  
 import java.io.File;
 import java.util.List;
 import java.util.Set;
 
 
 public class MavenModelResolver implements ModelResolver
 {
 
    private final List<RemoteRepositoryrepositories;
    private final List<RemoteRepositoryexternalRepositories;
    private final Set<StringrepositoryIds;
 
    private final RepositorySystem system;
    private final RepositorySystemSession session;

   
Creates a new Maven repository resolver. This resolver uses service available to Maven to create an artifact resolution chain

Parameters:
system the Maven based implementation of the org.eclipse.aether.RepositorySystem
session the current Maven execution session
remoteRepositories the list of available Maven repositories
 
             List<RemoteRepositoryremoteRepositories)
    {
       this. = system;
       this. = session;
 
       // RemoteRepository is mutable
       this. = new ArrayList<RemoteRepository>(remoteRepositories.size());
       for (final RemoteRepository remoteRepository : remoteRepositories)
       {
          this..add(new RemoteRepository.Builder(remoteRepository).build());
       }
 
       this. = new HashSet<String>(.size());
 
       for (final RemoteRepository repository : )
       {
          .add(repository.getId());
       }
    }

   
Cloning constructor

Parameters:
origin
 
    private MavenModelResolver(MavenModelResolver origin)
    {
       this(origin.systemorigin.sessionorigin.repositories);
    }
 
    /*
     * (non-Javadoc)
     * 
     * @see org.apache.maven.model.resolution.ModelResolver#addRepository(org.apache.maven.model.Repository)
     */
    @Override
    public void addRepository(Repository repositorythrows InvalidRepositoryException
    {
       if (.contains(repository.getId()))
       {
          return;
       }
 
       .add(repository.getId());
       .add(new RemoteRepository.Builder(repository.getId(), repository.getName(), repository.getUrl())
                .build());
    }
 
    /*
    * (non-Javadoc)
    * 
    * @see org.apache.maven.model.resolution.ModelResolver#newCopy()
    */
   public ModelResolver newCopy()
   {
      return new MavenModelResolver(this);
   }
   /*
    * (non-Javadoc)
    * 
    * @see org.apache.maven.model.resolution.ModelResolver#resolveModel(java.lang.String, java.lang.String,
    * java.lang.String)
    */
   public ModelSource resolveModel(String groupIdString artifactIdString version)
            throws UnresolvableModelException
   {
      Artifact pomArtifact = new DefaultArtifact(groupIdartifactId"""pom"version);
      try
      {
         final ArtifactRequest request = new ArtifactRequest(pomArtifactnull);
         pomArtifact = .resolveArtifact(request).getArtifact();
      }
      catch (ArtifactResolutionException e)
      {
         throw new UnresolvableModelException("Failed to resolve POM for " + groupId + ":" + artifactId + ":"
                  + version + " due to " + e.getMessage(), groupIdartifactIdversione);
      }
      final File pomFile = pomArtifact.getFile();
      return new FileModelSource(pomFile);
   }
   public ModelSource resolveModel(Parent parent)
            throws UnresolvableModelException
   {
      // FIXME: Support version range. See DefaultModelResolver
      return resolveModel(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
   }
   /*
    * (non-Javadoc)
    * 
    * @see org.apache.maven.model.resolution.ModelResolver#resetRepositories()
    */
   public void resetRepositories()
   {
      this..clear();
      this..clear();
   }
New to GrepCode? Check out our FAQ X