Package org.eclipse.aether

Examples of org.eclipse.aether.RepositorySystem


      this.mavenContainer = new MavenContainer();
   }

   public Model loadPomFromFile(File pomFile, String... profiles)
   {
      RepositorySystem system = mavenContainer.getRepositorySystem();
      Settings settings = mavenContainer.getSettings();
      DefaultRepositorySystemSession session = mavenContainer.setupRepoSession(system, settings);
      final DefaultModelBuildingRequest request = new DefaultModelBuildingRequest()
               .setSystemProperties(System.getProperties())
               .setPomFile(pomFile)
View Full Code Here


            Settings settings = mavenContainer.getSettings();
            // TODO this needs to be configurable via .forge
            // TODO this reference to the M2_REPO should probably be centralized
            MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();

            RepositorySystem repositorySystem = plexus.lookup(RepositorySystem.class);
            MavenExecutionRequestPopulator requestPopulator = plexus.lookup(MavenExecutionRequestPopulator.class);

            requestPopulator.populateFromSettings(executionRequest, settings);
            requestPopulator.populateDefaults(executionRequest);

            ProjectBuildingRequest request = executionRequest.getProjectBuildingRequest();

            org.apache.maven.artifact.repository.ArtifactRepository localRepository = RepositoryUtils
                     .toArtifactRepository("local",
                              new File(settings.getLocalRepository()).toURI().toURL().toString(), null, true, true);
            request.setLocalRepository(localRepository);

            List<org.apache.maven.artifact.repository.ArtifactRepository> settingsRepos = new ArrayList<org.apache.maven.artifact.repository.ArtifactRepository>(
                     request.getRemoteRepositories());
            List<String> activeProfiles = settings.getActiveProfiles();

            Map<String, Profile> profiles = settings.getProfilesAsMap();

            for (String id : activeProfiles)
            {
               Profile profile = profiles.get(id);
               if (profile != null)
               {
                  List<Repository> repositories = profile.getRepositories();
                  for (Repository repository : repositories)
                  {
                     settingsRepos.add(RepositoryUtils.convertFromMavenSettingsRepository(repository));
                  }
               }
            }
            request.setRemoteRepositories(settingsRepos);
            request.setSystemProperties(System.getProperties());

            DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
            Proxy activeProxy = settings.getActiveProxy();
            if (activeProxy != null)
            {
               DefaultProxySelector dps = new DefaultProxySelector();
               dps.add(RepositoryUtils.convertFromMavenProxy(activeProxy), activeProxy.getNonProxyHosts());
               repositorySession.setProxySelector(dps);
            }
            LocalRepository localRepo = new LocalRepository(settings.getLocalRepository());

            repositorySession.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(repositorySession,
                     localRepo));
            repositorySession.setOffline(settings.isOffline());
            List<Mirror> mirrors = executionRequest.getMirrors();
            if (mirrors != null)
            {
View Full Code Here

      this.mavenContainer = new MavenContainer();
   }

   public Model loadPomFromFile(File pomFile, String... profiles)
   {
      RepositorySystem system = mavenContainer.getRepositorySystem();
      Settings settings = mavenContainer.getSettings();
      DefaultRepositorySystemSession session = mavenContainer.setupRepoSession(system, settings);
      final DefaultModelBuildingRequest request = new DefaultModelBuildingRequest()
               .setSystemProperties(System.getProperties())
               .setPomFile(pomFile)
View Full Code Here

            Settings settings = mavenContainer.getSettings();
            // TODO this needs to be configurable via .forge
            // TODO this reference to the M2_REPO should probably be centralized
            MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();

            RepositorySystem repositorySystem = plexus.lookup(RepositorySystem.class);
            MavenExecutionRequestPopulator requestPopulator = plexus.lookup(MavenExecutionRequestPopulator.class);

            requestPopulator.populateFromSettings(executionRequest, settings);
            requestPopulator.populateDefaults(executionRequest);

            ProjectBuildingRequest request = executionRequest.getProjectBuildingRequest();

            org.apache.maven.artifact.repository.ArtifactRepository localRepository = RepositoryUtils
                     .toArtifactRepository("local",
                              new File(settings.getLocalRepository()).toURI().toURL().toString(), null, true, true);
            request.setLocalRepository(localRepository);

            List<org.apache.maven.artifact.repository.ArtifactRepository> settingsRepos = new ArrayList<org.apache.maven.artifact.repository.ArtifactRepository>(
                     request.getRemoteRepositories());
            List<String> activeProfiles = settings.getActiveProfiles();

            Map<String, Profile> profiles = settings.getProfilesAsMap();

            for (String id : activeProfiles)
            {
               Profile profile = profiles.get(id);
               if (profile != null)
               {
                  List<Repository> repositories = profile.getRepositories();
                  for (Repository repository : repositories)
                  {
                     settingsRepos.add(RepositoryUtils.convertFromMavenSettingsRepository(repository));
                  }
               }
            }
            request.setRemoteRepositories(settingsRepos);
            request.setSystemProperties(System.getProperties());

            DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
            Proxy activeProxy = settings.getActiveProxy();
            if (activeProxy != null)
            {
               DefaultProxySelector dps = new DefaultProxySelector();
               dps.add(RepositoryUtils.convertFromMavenProxy(activeProxy), activeProxy.getNonProxyHosts());
               repositorySession.setProxySelector(dps);
            }
            LocalRepository localRepo = new LocalRepository(settings.getLocalRepository());

            repositorySession.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(repositorySession,
                     localRepo));
            repositorySession.setOffline(settings.isOffline());
            List<Mirror> mirrors = executionRequest.getMirrors();
            DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
            if (mirrors != null)
View Full Code Here

   @Override
   public Set<Dependency> resolveDependencies(DependencyQuery query)
   {
      Set<Dependency> result = new HashSet<Dependency>();
      Predicate<Dependency> filter = query.getDependencyFilter();
      RepositorySystem system = container.getRepositorySystem();
      Settings settings = container.getSettings();

      DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);

      Artifact queryArtifact = MavenConvertUtils.coordinateToMavenArtifact(query.getCoordinate());

      List<RemoteRepository> remoteRepos = MavenRepositories.getRemoteRepositories(container, settings, query);

      CollectRequest collectRequest = new CollectRequest(new org.eclipse.aether.graph.Dependency(queryArtifact,
               query.getScopeType()), remoteRepos);

      DependencyRequest request = new DependencyRequest(collectRequest, null);

      DependencyResult artifacts;
      try
      {
         artifacts = system.resolveDependencies(session, request);
      }
      catch (NullPointerException e)
      {
         throw new RuntimeException("Could not resolve dependencies from Query [" + query
                  + "] due to underlying exception", e);
View Full Code Here

         else if (!version.matches("(\\(|\\[).*?(\\)|\\])"))
         {
            dep = CoordinateBuilder.create(dep).setVersion("[" + version + "]");
         }

         RepositorySystem maven = container.getRepositorySystem();
         Settings settings = container.getSettings();

         DefaultRepositorySystemSession session = container.setupRepoSession(maven, settings);
         Artifact artifact = MavenConvertUtils.coordinateToMavenArtifact(dep);

         List<RemoteRepository> remoteRepos = MavenRepositories.getRemoteRepositories(container, settings, query);

         VersionRangeRequest rangeRequest = new VersionRangeRequest(artifact, remoteRepos, null);

         VersionRangeResult rangeResult = maven.resolveVersionRange(session, rangeRequest);
         return rangeResult;
      }
      catch (Exception e)
      {
         throw new RuntimeException("Failed to look up versions for [" + dep + "]", e);
View Full Code Here

   }

   @Override
   public Dependency resolveArtifact(DependencyQuery query)
   {
      RepositorySystem system = container.getRepositorySystem();
      Settings settings = container.getSettings();

      List<RemoteRepository> remoteRepos = MavenRepositories.getRemoteRepositories(container, settings, query);

      DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
      Artifact queryArtifact = MavenConvertUtils.coordinateToMavenArtifact(query.getCoordinate());
      ArtifactRequest request = new ArtifactRequest(queryArtifact, remoteRepos, null);
      try
      {
         ArtifactResult resolvedArtifact = system.resolveArtifact(session, request);
         Artifact artifact = resolvedArtifact.getArtifact();

         @SuppressWarnings("unchecked")
         FileResource<?> artifactResource = factory.create(FileResource.class, artifact.getFile());
View Full Code Here

   @Override
   public org.jboss.forge.addon.dependencies.DependencyNode resolveDependencyHierarchy(final DependencyQuery query)
   {
      try
      {
         RepositorySystem system = container.getRepositorySystem();
         Settings settings = container.getSettings();
         DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
         session.setDependencyTraverser(new DependencyTraverser()
         {
            @Override
            public boolean traverseDependency(org.eclipse.aether.graph.Dependency dependency)
            {
               if (query.getScopeType() != null)
                  return query.getScopeType().equals(dependency.getScope());
               else
                  return !"test".equals(dependency.getScope());
            }

            @Override
            public DependencyTraverser deriveChildTraverser(DependencyCollectionContext context)
            {
               return this;
            }
         });
         session.setDependencySelector(new ScopeDependencySelector("test"));

         final CoordinateBuilder coord = CoordinateBuilder.create(query.getCoordinate());
         Artifact queryArtifact = MavenConvertUtils.coordinateToMavenArtifact(coord);

         List<RemoteRepository> remoteRepos = MavenRepositories.getRemoteRepositories(container, settings, query);
         CollectRequest collectRequest = new CollectRequest(new org.eclipse.aether.graph.Dependency(queryArtifact,
                  null), remoteRepos);

         DependencyRequest dr = new DependencyRequest(collectRequest, null);

         DependencyResult result = system.resolveDependencies(session, dr);
         DependencyNodeBuilder hierarchy = MavenConvertUtils.toDependencyNode(factory, null, result.getRoot());
         return hierarchy;
      }
      catch (Exception e)
      {
View Full Code Here

         if (Strings.isNullOrEmpty(query.getCoordinate().getVersion()))
         {
            throw new IllegalArgumentException("Dependency query coordinate version must be specified.");
         }

         RepositorySystem system = container.getRepositorySystem();
         Settings settings = container.getSettings();

         DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
         Artifact artifact = MavenConvertUtils.coordinateToMavenArtifact(query.getCoordinate());

         List<RemoteRepository> mavenRepositories = MavenRepositories.getRemoteRepositories(container, settings, query);
         ArtifactDescriptorRequest ar = new ArtifactDescriptorRequest(artifact, mavenRepositories, null);
         ArtifactDescriptorResult results = system.readArtifactDescriptor(session, ar);

         Artifact a = results.getArtifact();
         Dependency d = DependencyBuilder.create().setArtifactId(a.getArtifactId()).setGroupId(a.getGroupId())
                  .setVersion(a.getBaseVersion());
View Full Code Here

         MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
         MavenExecutionRequestPopulator populator = plexus.lookup(MavenExecutionRequestPopulator.class);
         populator.populateFromSettings(executionRequest, container.getSettings());
         populator.populateDefaults(executionRequest);
         RepositorySystem system = plexus.lookup(RepositorySystem.class);
         ProjectBuildingRequest request = executionRequest.getProjectBuildingRequest();

         ArtifactRepository localRepository = RepositoryUtils.toArtifactRepository("local",
                  new File(settings.getLocalRepository()).toURI().toURL().toString(), null, true, true);
         request.setLocalRepository(localRepository);

         List<ArtifactRepository> settingsRepos = new ArrayList<>(request.getRemoteRepositories());
         List<String> activeProfiles = settings.getActiveProfiles();

         Map<String, Profile> profiles = settings.getProfilesAsMap();

         for (String id : activeProfiles)
         {
            Profile profile = profiles.get(id);
            if (profile != null)
            {
               List<Repository> repositories = profile.getRepositories();
               for (Repository repository : repositories)
               {
                  settingsRepos.add(RepositoryUtils.convertFromMavenSettingsRepository(repository));
               }
            }
         }
         request.setRemoteRepositories(settingsRepos);
         request.setSystemProperties(System.getProperties());

         DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
         Proxy activeProxy = settings.getActiveProxy();
         if (activeProxy != null)
         {
            DefaultProxySelector dps = new DefaultProxySelector();
            dps.add(RepositoryUtils.convertFromMavenProxy(activeProxy), activeProxy.getNonProxyHosts());
            repositorySession.setProxySelector(dps);
         }
         LocalRepository localRepo = new LocalRepository(settings.getLocalRepository());
         repositorySession.setLocalRepositoryManager(system.newLocalRepositoryManager(repositorySession, localRepo));
         repositorySession.setOffline(offline);
         List<Mirror> mirrors = executionRequest.getMirrors();
         if (mirrors != null)
         {
            DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
View Full Code Here

TOP

Related Classes of org.eclipse.aether.RepositorySystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.