Search in sources :

Example 66 with DefaultDependencyDescriptor

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

the class IvyRepResolverTest method testIvyRepWithLocalURL.

@Test
public void testIvyRepWithLocalURL() throws Exception {
    IvyRepResolver resolver = new IvyRepResolver();
    String rootpath = new File("test/repositories/1").getAbsolutePath();
    resolver.setName("testLocal");
    resolver.setIvyroot("file:" + rootpath);
    resolver.setIvypattern("[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.setArtroot("file:" + rootpath);
    resolver.setArtpattern("[organisation]/[module]/jars/[artifact]-[revision].[ext]");
    resolver.setSettings(settings);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    DefaultArtifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "mod1.1", "jar", "jar");
    DownloadReport report = resolver.download(new Artifact[] { artifact }, downloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
    // test to ask to download again, should use cache
    report = resolver.download(new Artifact[] { artifact }, downloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) 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) File(java.io.File) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 67 with DefaultDependencyDescriptor

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

the class JarResolverTest method testUrl.

@Test
public void testUrl() throws Exception {
    JarResolver resolver = new JarResolver();
    resolver.setName("jarresolver1");
    resolver.setUrl(new File("test/jar-repos/jarrepo1.jar").toURI().toURL().toExternalForm());
    resolver.addIvyPattern("[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.addArtifactPattern("[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    resolver.setSettings(settings);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
}
Also used : ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) File(java.io.File) Test(org.junit.Test)

Example 68 with DefaultDependencyDescriptor

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

the class JarResolverTest method testSimpleFile.

@Test
public void testSimpleFile() throws Exception {
    JarResolver resolver = new JarResolver();
    resolver.setName("jarresolver1");
    resolver.setFile(new File("test/jar-repos/jarrepo1.jar").getAbsolutePath());
    resolver.addIvyPattern("[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.addArtifactPattern("[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    resolver.setSettings(settings);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
}
Also used : ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) File(java.io.File) Test(org.junit.Test)

Example 69 with DefaultDependencyDescriptor

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

the class Maven2LocalTest method testUseMetadataForListing.

@Test
public void testUseMetadataForListing() throws Exception {
    IBiblioResolver resolver = maven2Resolver();
    ResolvedModuleRevision m = resolver.getDependency(new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org.apache", "test-metadata", "latest.integration"), false), data);
    assertNotNull(m);
    // should trust the metadata (latest=1.1) instead of listing revisions (latest=1.2)
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-metadata", "1.1"), m.getId());
}
Also used : ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 70 with DefaultDependencyDescriptor

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

the class Maven2LocalTest method testNotUseMetadataForListing.

@Test
public void testNotUseMetadataForListing() throws Exception {
    IBiblioResolver resolver = maven2Resolver();
    resolver.setUseMavenMetadata(false);
    ResolvedModuleRevision m = resolver.getDependency(new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org.apache", "test-metadata", "latest.integration"), false), data);
    assertNotNull(m);
    // should trust listing revisions (latest=1.2) instead of the metadata (latest=1.1)
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-metadata", "1.2"), m.getId());
}
Also used : ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Aggregations

DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)80 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)61 Test (org.junit.Test)60 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)47 GregorianCalendar (java.util.GregorianCalendar)25 Date (java.util.Date)23 Artifact (org.apache.ivy.core.module.descriptor.Artifact)23 File (java.io.File)22 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)19 DownloadReport (org.apache.ivy.core.report.DownloadReport)18 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)16 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)12 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)9 DownloadOptions (org.apache.ivy.core.resolve.DownloadOptions)9 LatestRevisionStrategy (org.apache.ivy.plugins.latest.LatestRevisionStrategy)7 Configuration (org.apache.ivy.core.module.descriptor.Configuration)6 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)5 ModuleId (org.apache.ivy.core.module.id.ModuleId)5 BufferedReader (java.io.BufferedReader)3 Locale (java.util.Locale)3