public void testUpdateWithExcludeConfigurations4() throws Exception {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    URL settingsUrl =
        new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-update-excludedconfs4.xml")
            .toURL();
    XmlModuleDescriptorUpdater.update(
        settingsUrl,
        buffer,
        getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] {"myconf2"}));

    XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
    ModuleDescriptor updatedMd =
        parser.parseDescriptor(
            new IvySettings(),
            new ByteArrayInputStream(buffer.toByteArray()),
            new BasicResource("test", false, 0, 0, false),
            true);

    // test the number of configurations
    Artifact[] artifacts = updatedMd.getAllArtifacts();
    assertNotNull("Published artifacts shouldn't be null", artifacts);
    assertEquals("Number of published artifacts incorrect", 4, artifacts.length);

    // test that the correct configuration has been removed
    for (int i = 0; i < artifacts.length; i++) {
      Artifact current = artifacts[i];
      List currentConfs = Arrays.asList(current.getConfigurations());
      assertTrue(
          "myconf2 hasn't been removed for artifact " + current.getName(),
          !currentConfs.contains("myconf2"));
    }
  }
Exemplo n.º 2
0
 protected ResolvedResource getArtifactRef(Artifact artifact, Date date) {
   IvyContext.getContext().set(getName() + ".artifact", artifact);
   try {
     ResolvedResource ret = findArtifactRef(artifact, date);
     if (ret == null && artifact.getUrl() != null) {
       URL url = artifact.getUrl();
       Message.verbose("\tusing url for " + artifact + ": " + url);
       logArtifactAttempt(artifact, url.toExternalForm());
       Resource resource;
       if ("file".equals(url.getProtocol())) {
         File f;
         try {
           f = new File(new URI(url.toExternalForm()));
         } catch (URISyntaxException e) {
           // unexpected, try to get the best of it
           f = new File(url.getPath());
         }
         resource = new FileResource(new FileRepository(), f);
       } else {
         resource = new URLResource(url);
       }
       ret = new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision());
     }
     return ret;
   } finally {
     IvyContext.getContext().set(getName() + ".artifact", null);
   }
 }
Exemplo n.º 3
0
  private ModuleDescriptor findProject(DependencyDescriptor descriptor) {
    String projectPathValue = descriptor.getAttribute(DependencyDescriptorFactory.PROJECT_PATH_KEY);
    if (projectPathValue == null) {
      return null;
    }
    Project project = gradle.getRootProject().project(projectPathValue);
    Module projectModule = ((ProjectInternal) project).getModule();
    ModuleDescriptor projectDescriptor =
        moduleDescriptorConverter.convert(
            project.getConfigurations().getAll(),
            projectModule,
            IvyContext.getContext().getIvy().getSettings());

    for (DependencyArtifactDescriptor artifactDescriptor : descriptor.getAllDependencyArtifacts()) {
      for (Artifact artifact : projectDescriptor.getAllArtifacts()) {
        if (artifact.getName().equals(artifactDescriptor.getName())
            && artifact.getExt().equals(artifactDescriptor.getExt())) {
          String path =
              artifact.getExtraAttribute(DefaultIvyDependencyPublisher.FILE_PATH_EXTRA_ATTRIBUTE);
          ReflectionUtil.invoke(
              artifactDescriptor,
              "setExtraAttribute",
              new Object[] {DefaultIvyDependencyPublisher.FILE_PATH_EXTRA_ATTRIBUTE, path});
        }
      }
    }

    return projectDescriptor;
  }
Exemplo n.º 4
0
 @Override
 protected ResolvedResource findArtifactRef(Artifact artifact, Date date) {
   String path =
       artifact.getExtraAttribute(DefaultIvyDependencyPublisher.FILE_PATH_EXTRA_ATTRIBUTE);
   if (path == null) {
     return null;
   }
   File file = new File(path);
   return new ResolvedResource(
       new FileResource(new FileRepository(), file), artifact.getId().getRevision());
 }
Exemplo n.º 5
0
 public DefaultResolvedArtifact(
     ResolvedDependency resolvedDependency, Artifact artifact, Factory<File> artifactSource) {
   this.resolvedDependency = resolvedDependency;
   // Unpack the stuff that we're interested from the artifact and discard. The artifact instance
   // drags in a whole pile of stuff that
   // we don't want to retain references to.
   this.name = artifact.getName();
   this.type = artifact.getType();
   this.ext = artifact.getExt();
   this.extraAttributes = new HashMap<String, String>(artifact.getQualifiedExtraAttributes());
   this.artifactSource = artifactSource;
 }
Exemplo n.º 6
0
 @Test
 public void init() {
   assertSame(testPom, artifactPom.getPom());
   assertEquals(expectedArtifact, artifactPom.getArtifact());
   assertEquals(expectedFile, artifactPom.getArtifactFile());
   checkPom(
       expectedArtifact.getModuleRevisionId().getOrganisation(),
       expectedArtifact.getName(),
       expectedArtifact.getType(),
       expectedArtifact.getModuleRevisionId().getRevision(),
       expectedArtifact.getExtraAttribute(DependencyManager.CLASSIFIER));
 }
Exemplo n.º 7
0
 @Test
 public void initWithCustomPomSettings() {
   testPom.setArtifactId(expectedArtifact.getName() + "X");
   testPom.setGroupId(expectedArtifact.getModuleRevisionId().getOrganisation() + "X");
   testPom.setVersion(expectedArtifact.getModuleRevisionId().getRevision() + "X");
   testPom.setPackaging(expectedArtifact.getType() + "X");
   testPom.setClassifier(expectedArtifact.getExtraAttribute(DependencyManager.CLASSIFIER) + "X");
   artifactPom = new DefaultArtifactPom(testPom, expectedArtifact, expectedFile);
   assertEquals(expectedArtifact, artifactPom.getArtifact());
   assertEquals(expectedFile, artifactPom.getArtifactFile());
   checkPom(
       testPom.getGroupId(),
       testPom.getArtifactId(),
       testPom.getPackaging(),
       testPom.getVersion(),
       testPom.getClassifier());
 }
Exemplo n.º 8
0
 @Override
 public DownloadReport download(Artifact[] artifacts, DownloadOptions options) {
   DownloadReport dr = new DownloadReport();
   for (Artifact artifact : artifacts) {
     ArtifactDownloadReport artifactDownloadReport = new ArtifactDownloadReport(artifact);
     String path =
         artifact.getExtraAttribute(DefaultIvyDependencyPublisher.FILE_PATH_EXTRA_ATTRIBUTE);
     if (path == null) {
       artifactDownloadReport.setDownloadStatus(DownloadStatus.FAILED);
     } else {
       File file = new File(path);
       artifactDownloadReport.setDownloadStatus(DownloadStatus.SUCCESSFUL);
       artifactDownloadReport.setArtifactOrigin(new ArtifactOrigin(artifact, true, getName()));
       artifactDownloadReport.setLocalFile(file);
       artifactDownloadReport.setSize(file.length());
     }
     dr.addArtifactReport(artifactDownloadReport);
   }
   return dr;
 }
Exemplo n.º 9
0
 private File downloadTimestampedVersion(Artifact artifact, String timestampedVersion)
     throws IOException {
   final ModuleRevisionId artifactModuleRevisionId = artifact.getModuleRevisionId();
   final ModuleRevisionId moduleRevisionId =
       ModuleRevisionId.newInstance(
           artifactModuleRevisionId.getOrganisation(),
           artifactModuleRevisionId.getName(),
           artifactModuleRevisionId.getRevision(),
           WrapUtil.toMap("timestamp", timestampedVersion));
   final Artifact artifactWithResolvedModuleRevisionId =
       DefaultArtifact.cloneWithAnotherMrid(artifact, moduleRevisionId);
   return download(artifactWithResolvedModuleRevisionId);
 }
Exemplo n.º 10
0
 public void download(Artifact artifact, Resource resource, File dest) throws IOException {
   if (dest.exists()) {
     dest.delete();
   }
   File part = new File(dest.getAbsolutePath() + ".part");
   if (resource.getName().equals(String.valueOf(artifact.getUrl()))) {
     if (part.getParentFile() != null) {
       part.getParentFile().mkdirs();
     }
     extartifactrep.get(resource.getName(), part);
   } else {
     getAndCheck(resource, part);
   }
   if (!part.renameTo(dest)) {
     throw new IOException(
         "impossible to move part file to definitive one: " + part + " -> " + dest);
   }
 }
Exemplo n.º 11
0
 private boolean isIgnorable(Artifact artifact) {
   return artifact.getType().equals("ivy");
 }
Exemplo n.º 12
0
 public void resolve(Artifact artifact, BuildableArtifactResolveResult result) {
   String path =
       artifact.getExtraAttribute(
           DefaultIvyDependencyPublisher.FILE_ABSOLUTE_PATH_EXTRA_ATTRIBUTE);
   result.resolved(new File(path));
 }