Package org.sonatype.nexus.proxy.maven.gav

Examples of org.sonatype.nexus.proxy.maven.gav.Gav


  //        Assert.assertEquals( "/extra/dot/artifact/1.0/artifact-1.0.xml", request.getRequestPath() );
  //    }

  @Test
  public void testGroupStartsWithDot() throws Exception {
    Gav gav = new Gav(".meta/foo/bar", "artifact", "1.0", null, "xml", null, null, null, false, null, false, null);
    MavenRepository mavenRepository = (MavenRepository) this.getRepositoryRegistry().getRepository("repo1");
    ArtifactStoreRequest request = new ArtifactStoreRequest(mavenRepository, gav, true, false);

    Assert.assertEquals("/.meta/foo/bar/artifact/1.0/artifact-1.0.xml", request.getRequestPath());
  }
View Full Code Here


        return true;
      }
    }

    // we are using Gav to test the path
    final Gav gav = getGavCalculator().pathToGav(request.getRequestPath());

    if (gav == null) {
      return true;
    }
    else {
      if (gav.isSnapshot()) {
        // snapshots goes if enabled
        return RepositoryPolicy.SNAPSHOT.equals(getRepositoryPolicy());
      }
      else {
        return RepositoryPolicy.RELEASE.equals(getRepositoryPolicy());
View Full Code Here

    if (M1ArtifactRecognizer.isSnapshot(item.getPath())) {
      return isOld(getArtifactMaxAge(), item);
    }

    // we are using Gav to test the path
    final Gav gav = gavCalculator.pathToGav(item.getPath());

    if (gav == null) {
      // this is not an artifact, it is just any "file"
      return super.isOld(item);
    }
View Full Code Here

        return true;
      }
    }

    // we are using Gav to test the path
    final Gav gav = getGavCalculator().pathToGav(request.getRequestPath());

    if (gav == null) {
      return true;
    }
    else {
      if (gav.isSnapshot()) {
        // snapshots goes if enabled
        return RepositoryPolicy.SNAPSHOT.equals(getRepositoryPolicy());
      }
      else {
        return RepositoryPolicy.RELEASE.equals(getRepositoryPolicy());
View Full Code Here

    if (M2ArtifactRecognizer.isSnapshot(item.getPath())) {
      return isOld(getArtifactMaxAge(), item);
    }

    // we are using Gav to test the path
    final Gav gav = getGavCalculator().pathToGav(item.getPath());

    if (gav == null) {
      // this is not an artifact, it is just any "file"
      return super.isOld(item);
    }
View Full Code Here

   * This method will in case of released artifact request just locate it, and return if found. In case of snapshot
   * repository, if it needs resolving, will resolve it 1st and than locate it. It will obey to the session (global
   * update policy, that correspondos to Maven CLI "-U" option.
   */
  public File findArtifact(Artifact artifact) {
    Gav gav = toGav(artifact);

    ArtifactStoreRequest gavRequest;

    for (MavenRepository mavenRepository : nexusWorkspace.getRepositories()) {
      gavRequest = new ArtifactStoreRequest(mavenRepository, gav, false, false);
View Full Code Here

  private Gav toGav(Artifact artifact) {
    // fix for bug in M2GavCalculator
    final String classifier = StringUtils.isEmpty(artifact.getClassifier()) ? null : artifact.getClassifier();

    final Gav gav =
        new Gav(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), classifier,
            artifact.getExtension(), null, null, null, false, null, false, null);

    return gav;
  }
View Full Code Here

  /**
   * Basically, this method will read the GA metadata, and return the "known versions".
   */
  public List<String> findVersions(Artifact artifact) {
    Gav gav = toGav(artifact);

    if (gav.isSnapshot()) {
      ArtifactStoreRequest gavRequest;

      for (MavenRepository mavenRepository : nexusWorkspace.getRepositories()) {
        gavRequest = new ArtifactStoreRequest(mavenRepository, gav, false, false);

        try {
          Gav snapshot = mavenRepository.getMetadataManager().resolveSnapshot(gavRequest, gav);
          return Collections.singletonList(snapshot.getVersion());
        }
        catch (Exception e) {
          // try next repo
          continue;
        }
View Full Code Here

      // we need maven repository for this operation, but we actually don't care is this
      // maven2 or mave1 repository! Let's handle this in generic way.
      MavenRepository mavenRepository = itemRepository.adaptToFacet(MavenRepository.class);

      // use maven repository's corresponding GavCalculator instead of "wired in" one!
      Gav gav = mavenRepository.getGavCalculator().pathToGav(itemPath);

      if (gav == null || gav.isSignature() || gav.isHash()) {
        // if we cannot calculate the gav, it is not a maven artifact (or hash/sig), return null;
        return null;
      }

      // if we are here, we have GAV, so just pack it and send it back
      Maven2ArtifactInfoResourceRespose response = new Maven2ArtifactInfoResourceRespose();
      Maven2ArtifactInfoResource data = new Maven2ArtifactInfoResource();
      response.setData(data);

      data.setGroupId(gav.getGroupId());
      data.setArtifactId(gav.getArtifactId());
      data.setBaseVersion(gav.getBaseVersion());
      data.setVersion(gav.getVersion());
      data.setExtension(gav.getExtension());
      data.setClassifier(gav.getClassifier());

      data.setDependencyXmlChunk(generateDependencyXml(gav));

      return response;
    }
View Full Code Here

      Repository repository = this.repositoryRegistry.getRepository(artifactInfo.repository);

      if (MavenRepository.class.isAssignableFrom(repository.getClass())) {
        MavenRepository mr = (MavenRepository) repository;

        Gav gav =
            new Gav(artifactInfo.groupId, artifactInfo.artifactId, artifactInfo.version,
                artifactInfo.classifier, mr.getArtifactPackagingMapper().getExtensionForPackaging(
                artifactInfo.packaging), null, null, null, false, null, false, null);

        ResourceStoreRequest req = new ResourceStoreRequest(mr.getGavCalculator().gavToPath(gav));
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.maven.gav.Gav

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.