Search in sources :

Example 51 with Artifact

use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.

the class P2DescriptorTest method testResolvePacked.

@Test
public void testResolvePacked() throws Exception {
    settings.setDefaultResolver("p2-with-packed");
    ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.junit", "4.10.0.v4_10_0_v20120426-0900");
    ResolvedModuleRevision rmr = p2WithPackedResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());
    assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
    DownloadOptions options = new DownloadOptions();
    DownloadReport report = p2WithPackedResolver.download(rmr.getDescriptor().getAllArtifacts(), options);
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
    assertNotNull(ar.getUnpackedLocalFile());
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DownloadOptions(org.apache.ivy.core.resolve.DownloadOptions) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Artifact(org.apache.ivy.core.module.descriptor.Artifact) Test(org.junit.Test)

Example 52 with Artifact

use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.

the class P2DescriptorTest method testResolveNotZipped.

@Test
public void testResolveNotZipped() throws Exception {
    settings.setDefaultResolver("p2-zipped");
    ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.eclipse.e4.core.services", "1.0.0.v20120521-2346");
    ResolvedModuleRevision rmr = p2ZippedResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());
    assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
    DownloadOptions options = new DownloadOptions();
    DownloadReport report = p2ZippedResolver.download(rmr.getDescriptor().getAllArtifacts(), options);
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
    assertNull(ar.getUnpackedLocalFile());
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DownloadOptions(org.apache.ivy.core.resolve.DownloadOptions) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Artifact(org.apache.ivy.core.module.descriptor.Artifact) Test(org.junit.Test)

Example 53 with Artifact

use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.

the class NameSpaceHelperTest method testTransformArtifactWithExtraAttributes.

@Test
public void testTransformArtifactWithExtraAttributes() {
    Artifact artifact = new DefaultArtifact(ArtifactRevisionId.newInstance(ModuleRevisionId.parse("org.apache#test;1.0"), "test", "jar", "jar", Collections.singletonMap("m:qualifier", "sources")), new Date(), null, false);
    MRIDTransformationRule r = new MRIDTransformationRule();
    r.addSrc(new MRIDRule("org.apache", "test", null));
    r.addDest(new MRIDRule("apache", "test", null));
    Artifact transformed = NameSpaceHelper.transform(artifact, r);
    assertEquals("apache#test;1.0", transformed.getModuleRevisionId().toString());
    assertEquals(Collections.singletonMap("m:qualifier", "sources"), transformed.getQualifiedExtraAttributes());
}
Also used : Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Date(java.util.Date) Test(org.junit.Test)

Example 54 with Artifact

use of org.apache.ivy.core.module.descriptor.Artifact in project gradle by gradle.

the class DefaultArtifactPomTest method cannotAddMultipleArtifactsWithTheSameTypeAndClassifier.

@Test
public void cannotAddMultipleArtifactsWithTheSameTypeAndClassifier() {
    // No classifier
    Artifact mainArtifact = createTestArtifact("someName", null);
    artifactPom.addArtifact(mainArtifact, new File("someFile"));
    assertIsDuplicate(mainArtifact, new File("someFile"));
    assertIsDuplicate(mainArtifact, new File("otherFile"));
    assertIsDuplicate(createTestArtifact("otherName", null), new File("otherFile"));
    // Classifier
    Artifact classifierArtifact = createTestArtifact("someName", "classifier");
    artifactPom.addArtifact(classifierArtifact, new File("classifierFile"));
    assertIsDuplicate(classifierArtifact, new File("someFile"));
    assertIsDuplicate(classifierArtifact, new File("otherFile"));
    assertIsDuplicate(createTestArtifact("otherName", "classifier"), new File("otherFile"));
}
Also used : File(java.io.File) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 55 with Artifact

use of org.apache.ivy.core.module.descriptor.Artifact in project gradle by gradle.

the class DefaultArtifactPomTest method pomWithMainArtifactAndMetadataArtifacts.

@Test
public void pomWithMainArtifactAndMetadataArtifacts() {
    Artifact mainArtifact = createTestArtifact("someName", null, "mainPackaging");
    File mainFile = new File("someFile");
    File metadataFile = new File("someMetadataFile");
    Artifact metadataArtifact = createTestArtifact("otherName", null, "sometype");
    artifactPom.addArtifact(mainArtifact, mainFile);
    artifactPom.addArtifact(metadataArtifact, metadataFile);
    assertThat(artifactPom.getArtifact().getName(), equalTo("someName"));
    assertThat(artifactPom.getArtifact().getExtension(), equalTo("mainPackaging"));
    assertThat(artifactPom.getArtifact().getType(), equalTo("mainPackaging"));
    assertThat(artifactPom.getArtifact().getClassifier(), nullValue());
    assertThat(artifactPom.getArtifact().getFile(), equalTo(mainFile));
    PublishArtifact artifact = singleItem(artifactPom.getAttachedArtifacts());
    assertThat(artifact.getName(), equalTo("someName"));
    assertThat(artifact.getExtension(), equalTo("sometype"));
    assertThat(artifact.getType(), equalTo("sometype"));
    assertThat(artifact.getClassifier(), nullValue());
    assertThat(artifact.getFile(), equalTo(metadataFile));
    assertThat(artifactPom.getPom().getGroupId(), equalTo("org"));
    assertThat(artifactPom.getPom().getArtifactId(), equalTo("someName"));
    assertThat(artifactPom.getPom().getVersion(), equalTo("1.0"));
    assertThat(artifactPom.getPom().getPackaging(), equalTo("mainPackaging"));
}
Also used : PublishArtifact(org.gradle.api.artifacts.PublishArtifact) File(java.io.File) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Aggregations

Artifact (org.apache.ivy.core.module.descriptor.Artifact)106 Test (org.junit.Test)68 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)59 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)55 File (java.io.File)53 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)31 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)30 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)28 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)25 Date (java.util.Date)22 DownloadReport (org.apache.ivy.core.report.DownloadReport)20 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)15 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)13 Configuration (org.apache.ivy.core.module.descriptor.Configuration)10 IOException (java.io.IOException)9 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)9 ParseException (java.text.ParseException)8 XmlModuleDescriptorParserTest (org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest)8 ResolveReport (org.apache.ivy.core.report.ResolveReport)7 DownloadOptions (org.apache.ivy.core.resolve.DownloadOptions)7