Package org.sonatype.nexus.proxy.maven.maven2

Examples of org.sonatype.nexus.proxy.maven.maven2.M2RepositoryConfiguration


  }

  public void doTestNEXUS4218(final String path, final String userAgent, final String remoteAddress)
      throws Exception
  {
    final M2Repository repository = (M2Repository) getResourceStore();
    // we check our expectation agains repository: it has to be Maven2 proxy repository
    Assert.assertTrue(repository.getRepositoryKind().isFacetAvailable(MavenProxyRepository.class));
    Assert.assertTrue(Maven2ContentClass.ID.equals(repository.getRepositoryContentClass().getId()));
    File repositoryLocalStorageDir =
        new File(
            new URL(((CRepositoryCoreConfiguration) repository.getCurrentCoreConfiguration()).getConfiguration(
                false).getLocalStorage().getUrl()).getFile());

    // create a request and equip it as needed
    final ResourceStoreRequest request = new ResourceStoreRequest(path);
    if (userAgent != null) {
      request.getRequestContext().put(AccessManager.REQUEST_AGENT, userAgent);
    }
    if (remoteAddress != null) {
      request.getRequestContext().put(AccessManager.REQUEST_REMOTE_ADDRESS, remoteAddress);
    }

    // invoke expire caches
    repository.expireCaches(request);

    // NO file should be pulled down
    {
      File artifactFile;
      if (!M2ArtifactRecognizer.isChecksum(path)) {
        artifactFile = new File(repositoryLocalStorageDir, path.substring(1));
      }
      else {
        artifactFile =
            new File(repositoryLocalStorageDir, path.substring(1, path.length() - ".sha1".length()));
      }
      Assert.assertFalse(artifactFile.exists());
    }

    // create a request and equip it as needed (requests should NOT be reused!)
    final ResourceStoreRequest retrieveRequest = new ResourceStoreRequest(path);
    if (userAgent != null) {
      retrieveRequest.getRequestContext().put(AccessManager.REQUEST_AGENT, userAgent);
    }
    if (remoteAddress != null) {
      retrieveRequest.getRequestContext().put(AccessManager.REQUEST_REMOTE_ADDRESS, remoteAddress);
    }

    // now do a fetch
    // this verifies that an assertion ("path in question does not exists in proxy cache but does exists on remote")
    // also verifies that cstamas did not mistype the paths in @Test method ;)
    repository.retrieveItem(retrieveRequest);

    // files SHOULD be pulled down
    {
      File artifactFile;
      if (!M2ArtifactRecognizer.isChecksum(path)) {
View Full Code Here


  }

  private boolean cachedHashItem(final String itemPath, String suffix)
      throws Exception
  {
    final M2Repository repository = getRepository();
    try {
      AbstractStorageItem item =
          repository.getLocalStorage().retrieveItem(repository, new ResourceStoreRequest(itemPath, true, false));

      String attrname;
      if (ChecksumContentValidator.SUFFIX_SHA1.equals(suffix)) {
        attrname = ChecksumContentValidator.ATTR_REMOTE_SHA1;
      }
View Full Code Here

    assertFalse("repo is not proxied", patient.getRepositoryKind().isFacetAvailable(ProxyRepository.class));
    assertFalse("repo is not proxied", patient.getRepositoryKind().isFacetAvailable(MavenProxyRepository.class));

    // do the conversion
    // forcing cast
    M2Repository repoToBeTreated = (M2Repository) patient;

    repoToBeTreated.setRemoteStorage(remoteRepositoryStorage);

    repoToBeTreated.setRemoteUrl("http://repo1.maven.org/maven2/");

    getApplicationConfiguration().saveConfiguration();

    // check
    assertFalse("repo is not hosted", patient.getRepositoryKind().isFacetAvailable(HostedRepository.class));
    assertFalse("repo is not hosted", patient.getRepositoryKind().isFacetAvailable(MavenHostedRepository.class));
    assertTrue("repo is proxied", patient.getRepositoryKind().isFacetAvailable(ProxyRepository.class));
    assertTrue("repo is proxied", patient.getRepositoryKind().isFacetAvailable(MavenProxyRepository.class));

    // now we just walk in, like nothing of above happened :)
    M2Repository afterTreatment =
        (M2Repository) getRepositoryRegistry().getRepositoryWithFacet(patient.getId(), MavenProxyRepository.class);

    assertNotNull("It should exists (heh, but NoSuchRepo exception should be thrown anyway)", afterTreatment);

    assertEquals("This should match, since they should be the same!", remoteRepositoryStorage.getProviderId(),
        afterTreatment.getRemoteStorage().getProviderId());

    // before NEXUS-5258, this test used to check that the provider was set. Nexus does not set the provider anymore
    // if it is the default provider, to let repos pick up the system default.

    assertEquals("Config should state the same as object is", afterTreatment.getRemoteUrl(),
        (((CRepositoryCoreConfiguration) afterTreatment.getCurrentCoreConfiguration())
            .getConfiguration(false)).getRemoteStorage().getUrl()
    );
  }
View Full Code Here

      throws Exception
  {
    List<String> reposes = new ArrayList<String>();
    for (String remoteRepoId : repoIds()) {
      // create proxy for remote
      M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
      CRepository repoConf = new DefaultCRepository();
      repoConf.setProviderRole(Repository.class.getName());
      repoConf.setProviderHint("maven2");
      repoConf.setId(remoteRepoId);
      repoConf.setName(remoteRepoId);
      repoConf.setNotFoundCacheActive(true);

      repoConf.setLocalStorage(new CLocalStorage());
      repoConf.getLocalStorage().setProvider("file");
      repoConf.getLocalStorage().setUrl(
          env
              .getApplicationConfiguration().getWorkingDirectory("proxy/store/" + remoteRepoId).toURI()
              .toURL().toString()
      );

      Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
      repoConf.setExternalConfiguration(ex);
      M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
      if (remoteRepoId.endsWith("-snapshot")) {
        exConf.setRepositoryPolicy(RepositoryPolicy.SNAPSHOT);
      }
      else {
        exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
      }
      exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
      exConf.setRoutingDiscoveryEnabled(false);

      repoConf.setRemoteStorage(new CRemoteStorage());
      repoConf.getRemoteStorage().setProvider(env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
      repoConf.getRemoteStorage().setUrl(server().getUrl() + "/" + remoteRepoId + "/");

      repo.configure(repoConf);

      // repo.setCacheManager( env.getCacheManager() );
      reposes.add(repo.getId());

      env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);

      env.getRepositoryRegistry().addRepository(repo);
    }

    // ading one hosted only
    M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");

    CRepository repoConf = new DefaultCRepository();

    repoConf.setProviderRole(Repository.class.getName());
    repoConf.setProviderHint("maven2");
    repoConf.setId("inhouse");

    repoConf.setLocalStorage(new CLocalStorage());
    repoConf.getLocalStorage().setProvider("file");
    repoConf.getLocalStorage().setUrl(
        env.getApplicationConfiguration().getWorkingDirectory("proxy/store/inhouse").toURI().toURL().toString());

    Xpp3Dom exRepo = new Xpp3Dom("externalConfiguration");
    repoConf.setExternalConfiguration(exRepo);
    M2RepositoryConfiguration exRepoConf = new M2RepositoryConfiguration(exRepo);
    exRepoConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
    exRepoConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);

    repo.configure(repoConf);

    reposes.add(repo.getId());

    env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);

    env.getRepositoryRegistry().addRepository(repo);

    // add a hosted snapshot repo
    M2Repository repoSnapshot = (M2Repository) env.lookup(Repository.class, "maven2");

    CRepository repoSnapshotConf = new DefaultCRepository();

    repoSnapshotConf.setProviderRole(Repository.class.getName());
    repoSnapshotConf.setProviderHint("maven2");
    repoSnapshotConf.setId("inhouse-snapshot");

    repoSnapshotConf.setLocalStorage(new CLocalStorage());
    repoSnapshotConf.getLocalStorage().setProvider("file");
    repoSnapshotConf.getLocalStorage().setUrl(
        env
            .getApplicationConfiguration().getWorkingDirectory("proxy/store/inhouse-snapshot").toURI().toURL()
            .toString()
    );

    Xpp3Dom exSnapRepo = new Xpp3Dom("externalConfiguration");
    repoSnapshotConf.setExternalConfiguration(exSnapRepo);
    M2RepositoryConfiguration exSnapRepoConf = new M2RepositoryConfiguration(exSnapRepo);
    exSnapRepoConf.setRepositoryPolicy(RepositoryPolicy.SNAPSHOT);
    exSnapRepoConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);

    repoSnapshot.configure(repoSnapshotConf);

    reposes.add(repoSnapshot.getId());

    env.getApplicationConfiguration().getConfigurationModel().addRepository(repoSnapshotConf);

    env.getRepositoryRegistry().addRepository(repoSnapshot);
View Full Code Here

      public void buildEnvironment(AbstractProxyTestEnvironment env)
          throws Exception
      {
        {
          // adding one proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY_REPO_ID);
          repoConf.setName(PROXY_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY_REPO_ID).toURI().toURL()
                  .toString()
          );
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server.getPort() + "/");
          repo.configure(repoConf);
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
      }
    };
View Full Code Here

          Files.write("dummy content".getBytes(), fakeArtifact);

          final List<String> reposes = new ArrayList<String>();
          {
            // adding one proxy
            final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
            CRepository repoConf = new DefaultCRepository();
            repoConf.setProviderRole(Repository.class.getName());
            repoConf.setProviderHint("maven2");
            repoConf.setId(PROXY_REPO_ID);
            repoConf.setName(PROXY_REPO_ID);
            repoConf.setNotFoundCacheActive(true);
            repoConf.setLocalStorage(new CLocalStorage());
            repoConf.getLocalStorage().setProvider("file");
            repoConf.getLocalStorage().setUrl(
                env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY_REPO_ID).toURI().toURL()
                    .toString());
            Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
            repoConf.setExternalConfiguration(ex);
            M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
            exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
            exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
            repoConf.setRemoteStorage(new CRemoteStorage());
            repoConf.getRemoteStorage().setProvider(
                env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
            repoConf.getRemoteStorage().setUrl("http://localhost:" + server.getPort() + "/");
            repo.configure(repoConf);
            // repo.setCacheManager( env.getCacheManager() );
            reposes.add(repo.getId());
            env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
            env.getRepositoryRegistry().addRepository(repo);
          }
        }
      };
View Full Code Here

          throws Exception
      {
        final List<String> reposes = new ArrayList<String>();
        {
          // adding one proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY1_REPO_ID);
          repoConf.setName(PROXY1_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY1_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server1.getPort() + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          reposes.add(repo.getId());
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // adding one proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY2_REPO_ID);
          repoConf.setName(PROXY2_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY2_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server2.getPort() + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          reposes.add(repo.getId());
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // adding one proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY3_REPO_ID);
          repoConf.setName(PROXY3_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY3_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server3.getPort() + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          // reposes.add( repo.getId() );
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
View Full Code Here

    request.setRootRef(new Reference("http://localhost:8081/nexus"));
    request.getAttributes().put(RoutingResourceSupport.REPOSITORY_ID_KEY, REPO_ID);
    Response.setCurrent(new Response(request));
    BaseUrlHolder.set("http://localhost:8081/nexus");
    try {
      final M2Repository repository = (M2Repository) lookup(RepositoryRegistry.class).getRepository(REPO_ID);

      {
        final RoutingStatusMessageWrapper payload = wlStatusResource.get(null, request, null, null);
        assertThat(payload, is(notNullValue()));
        assertThat(payload.getData().getPublishedUrl(), is(notNullValue()));
        assertThat(payload.getData().getPublishedUrl(), containsString(".meta/prefixes.txt"));
        assertThat(payload.getData().getPublishedUrl(), containsString(REPO_ID));
      }

      repository.setExposed(false);
      repository.commitChanges();

      {
        final RoutingStatusMessageWrapper payload = wlStatusResource.get(null, request, null, null);
        assertThat(payload, is(notNullValue()));
        assertThat(payload.getData().getPublishedUrl(), is(nullValue()));
      }

      repository.setExposed(true);
      repository.commitChanges();

      {
        final RoutingStatusMessageWrapper payload = wlStatusResource.get(null, request, null, null);
        assertThat(payload, is(notNullValue()));
        assertThat(payload.getData().getPublishedUrl(), is(notNullValue()));
View Full Code Here

          throws Exception
      {
        final List<String> reposes = new ArrayList<String>();
        {
          // adding one proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY_REPO_ID);
          repoConf.setName(PROXY_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + remoteServerPort + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          reposes.add(repo.getId());
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // add a group
View Full Code Here

          throws Exception
      {
        final List<String> reposes = new ArrayList<String>();
        {
          // adding 1st proxy, that is out of service
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY1_REPO_ID);
          repoConf.setName(PROXY1_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStatus(LocalStatus.OUT_OF_SERVICE.name()); // THIS REPO IS OUT OF SERVICE
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY1_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server.getPort() + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          reposes.add(repo.getId());
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // adding 2nd proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY2_REPO_ID);
          repoConf.setName(PROXY2_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY2_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server.getPort() + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          reposes.add(repo.getId());
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // adding one hosted
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(HOSTED_REPO_ID);
          repoConf.setName(HOSTED_REPO_ID);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + HOSTED_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom exRepo = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(exRepo);
          M2RepositoryConfiguration exRepoConf = new M2RepositoryConfiguration(exRepo);
          exRepoConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exRepoConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repo.configure(repoConf);
          reposes.add(repo.getId());
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // add a group
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.maven.maven2.M2RepositoryConfiguration

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.