Package org.sonatype.aether.repository

Examples of org.sonatype.aether.repository.RemoteRepository


               }
            }
            if (ar instanceof RemoteRepository)
            {
               ArtifactRequest request = new ArtifactRequest();
               RemoteRepository remoteRepo = new RemoteRepository(ar.getId(), ar.getContentType(),
                        ((RemoteRepository) ar).getUrl());
               request.addRepository(remoteRepo);
               request.setArtifact(artifact);

               try
View Full Code Here


      return session;
   }

   private RemoteRepository convertToMavenRepo(final DependencyRepository repo)
   {
      RemoteRepository remoteRepository = new RemoteRepository(repo.getId(), "default", repo.getUrl());
      Settings settings = container.getSettings();
      Proxy activeProxy = settings.getActiveProxy();
      if (activeProxy != null)
      {
         remoteRepository.setProxy(RepositoryUtils.convertFromMavenProxy(activeProxy));
      }
      return remoteRepository;
   }
View Full Code Here

    @Before
    public void setup()
        throws IOException
    {
        repository =
            new RemoteRepository( "test", "default",
                                  TestFileUtils.createTempDir( "test-remote-repository" ).toURL().toString() );
        session = new TestRepositorySystemSession();
        layout = new MavenDefaultLayout();
    }
View Full Code Here

        throws ArtifactTransferException, IOException
    {
        String enc = "%72%65%70%6F";
        File dir = TestFileUtils.createTempDir();
        String repoDir = dir.toURI().toURL().toString() + "/" + enc;
        repository = new RemoteRepository( "test", "default", repoDir );

        Artifact artifact = new DefaultArtifact( "gid", "aid", "jar", "ver" );
        String content = "test content";
        uploadArtifact( artifact, content );
View Full Code Here

        }

        public RemoteRepository before( RepositorySystemSession session, Map<String, Object> context )
            throws IOException
        {
            RemoteRepository repo = null;
            repoFile = TestFileUtils.createTempDir( "test-repo" );
            try
            {
                repo =
                    new RemoteRepository( "test-file", "default",
                                          repoFile.toURI().toURL().toString() );
            }
            catch ( MalformedURLException e )
            {
                throw new UnsupportedOperationException( "File.toURI().toURL() failed" );
View Full Code Here

            if (StringUtils.isNotBlank(snapshotRepoUrl)) {
                logger.debug("Enforcing snapshot repository for resolution: " + snapshotRepoUrl);
                RepositoryPolicy releasePolicy = new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN);
                RepositoryPolicy snapshotPolicy = new RepositoryPolicy(false, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN);
                releaseRepository = new RemoteRepository("artifactory-snapshot", "default", releaseRepoUrl);
                if (authentication != null) {
                    logger.debug("Enforcing repository authentication: " + authentication + " for snapshot resolution repository");
                    releaseRepository.setAuthentication(authentication);
                }
                if (proxy != null) {
                    logger.debug("Enforcing proxy: " + proxy + " for snapshot resolution repository");
                    releaseRepository.setProxy(proxy);
                }
                releaseRepository.setPolicy(false, releasePolicy);
                releaseRepository.setPolicy(true, snapshotPolicy);
            }

            if (StringUtils.isNotBlank(releaseRepoUrl)) {
                logger.debug("Enforcing release repository for resolution: " + releaseRepoUrl);
                boolean snapshotPolicyEnabled = snapshotRepository == null;
                String repositoryId = snapshotPolicyEnabled ? "artifactory-release-snapshot" : "artifactory-release";

                RepositoryPolicy releasePolicy = new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN);
                RepositoryPolicy snapshotPolicy = new RepositoryPolicy(snapshotPolicyEnabled, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN);
                releaseRepository = new RemoteRepository(repositoryId, "default", releaseRepoUrl);
                if (authentication != null) {
                    logger.debug("Enforcing repository authentication: " + authentication + " for release resolution repository");
                    releaseRepository.setAuthentication(authentication);
                }
                if (proxy != null) {
View Full Code Here

     */
    private void verifyArtifactoryResolutionEnforced(RepositoryEvent event) {
        if (event.getArtifact() == null || !(event.getRepository() instanceof RemoteRepository)) {
            return;
        }
        RemoteRepository repo = (RemoteRepository)event.getRepository();

        // In case the Artifactory resolver is not yet set, we wait for it first:
        if (!artifactoryRepositoriesEnforced) {
            synchronized (artifactoryRepositoriesEnforced) {
                if (!artifactoryRepositoriesEnforced) {
                    try {
                        artifactoryRepositoriesEnforced.wait();
                    } catch (InterruptedException e) {
                        logger.error("Failed while waiting for Artifactory repositories enforcement", e);
                    }
                }
            }
        }

        // Now that the resolver enforcement is done, we make sure that the Artifactory resolution repositories in the resolver are initialized:
        artifactoryResolver.initResolutionRepositories(event.getSession());

        // Take the Artifactory resolution repositories from the Artifactory resolver:
        RemoteRepository artifactorySnapshotRepo = artifactoryResolver.getSnapshotRepository(event.getSession());
        RemoteRepository artifactoryReleaseRepo = artifactoryResolver.getReleaseRepository(event.getSession());

        // If the artifact about to be downloaded was not handled by the Artifactory resolution resolver, but by the default resolver (before
        // it had been replaced), modify the repository URL:
        try {
            if (event.getArtifact().isSnapshot() && repo != artifactorySnapshotRepo) {
                logger.debug("Replacing resolution repository URL: " + repo + " with: " + artifactorySnapshotRepo.getUrl());
                Field url = RemoteRepository.class.getDeclaredField("url");
                url.setAccessible(true);
                url.set(repo, artifactorySnapshotRepo.getUrl());
                setRepositoryPolicy(repo);
            } else
            if (!event.getArtifact().isSnapshot() && repo != artifactoryReleaseRepo) {
                logger.debug("Replacing resolution repository URL: " + repo + " with: " + artifactoryReleaseRepo.getUrl());
                Field url = RemoteRepository.class.getDeclaredField("url");
                url.setAccessible(true);
                url.set(repo, artifactoryReleaseRepo.getUrl());
                setRepositoryPolicy(repo);
            }
        } catch (Exception e) {
            logger.error("Failed while replacing resolution repository URL", e);
        }
View Full Code Here

                  }
               }
               if (ar instanceof RemoteRepository)
               {
                  ArtifactRequest request = new ArtifactRequest();
                  RemoteRepository remoteRepo = new RemoteRepository(ar.getId(), ar.getContentType(),
                           ((RemoteRepository) ar).getUrl());
                  request.addRepository(remoteRepo);
                  request.setArtifact(artifact);

                  try
View Full Code Here

      return session;
   }

   private RemoteRepository convertToMavenRepo(final DependencyRepository repo)
   {
      RemoteRepository remoteRepository = new RemoteRepository(repo.getId(), "default", repo.getUrl());
      Settings settings = container.getSettings();
      Proxy activeProxy = settings.getActiveProxy();
      if (activeProxy != null)
      {
         remoteRepository.setProxy(RepositoryUtils.convertFromMavenProxy(activeProxy));
      }
      return remoteRepository;
   }
View Full Code Here

            hasCentral = true;
         }
      }
      if (!hasCentral)
      {
         RemoteRepository central = convertToMavenRepo(new DependencyRepositoryImpl(KnownRepository.CENTRAL.getId(),
                  KnownRepository.CENTRAL.getUrl()));
         central.setPolicy(true, new RepositoryPolicy().setEnabled(false));
         remoteRepos.add(central);
      }
      return remoteRepos;
   }
View Full Code Here

TOP

Related Classes of org.sonatype.aether.repository.RemoteRepository

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.