Search in sources :

Example 91 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport in project ant-ivy by apache.

the class ResolveTest method testResolveMultipleConfsWithConflicts.

/**
 * Test case for IVY-173.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-173">IVY-173</a>
 */
@Test
public void testResolveMultipleConfsWithConflicts() throws Exception {
    // mod6.2 has two confs compile and run
    // depends on mod1.2 2.1 in conf (compile->default)
    // depends on mod1.1 1.0 in conf (*->default)
    // depends on mod6.1 in conf (*->default)
    // mod6.1
    // depends on mod1.2 2.1
    // mod1.1
    // depends on mod1.2 2.0
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org6/mod6.2/ivys/ivy-0.5.xml"), getResolveOptions(new String[] { "compile", "run" }));
    assertNotNull(report);
    assertFalse(report.hasError());
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.2", "0.5");
    assertEquals(mrid, md.getModuleRevisionId());
    ConfigurationResolveReport crr = report.getConfigurationReport("compile");
    assertNotNull(crr);
    assertEquals(3, crr.getArtifactsNumber());
    crr = report.getConfigurationReport("run");
    assertNotNull(crr);
    assertEquals(3, crr.getArtifactsNumber());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org6", "mod6.1", "0.5")).exists());
    assertTrue(getArchiveFileInCache("org6", "mod6.1", "0.5", "mod6.1", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists());
    assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 92 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport in project ant-ivy by apache.

the class ResolveTest method testBranches2.

@Test
public void testBranches2() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/branches/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File("test/repositories/branches/bar/bar1/trunk/2/ivy.xml"), getResolveOptions(new String[] { "*" }).setValidate(false));
    assertFalse(report.hasError());
    assertTrue(getArchiveFileInCache(ivy, "foo#foo1#branch1;4", "foo1", "jar", "jar").exists());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 93 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport in project ant-ivy by apache.

the class ResolveTest method testResolveMaven2Snapshot2AsLatestIntegration.

/**
 * Test case for IVY-1036.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1036">IVY-1036</a>
 */
@Test
public void testResolveMaven2Snapshot2AsLatestIntegration() throws Exception {
    // here we test maven SNAPSHOT versions handling,
    // with m2 snapshotRepository/uniqueVersion set to true
    // but retrieving by latest.integration
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
    ResolveReport report = ivy.resolve(ModuleRevisionId.newInstance("org.apache", "test-SNAPSHOT2", "latest.integration"), getResolveOptions(new String[] { "*(public)" }), true);
    assertNotNull(report);
    assertFalse(report.hasError());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test-SNAPSHOT2", "2.0.2-SNAPSHOT")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-SNAPSHOT2", "2.0.2-SNAPSHOT", "test-SNAPSHOT2", "jar", "jar").exists());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 94 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport in project ant-ivy by apache.

the class ResolveTest method testResolveConflictInConf.

@Test
public void testResolveConflictInConf() throws Exception {
    // conflicts in separate confs are not conflicts
    // mod2.1 conf A depends on mod1.1 which depends on mod1.2 2.0
    // mod2.1 conf B depends on mod1.2 2.1
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.1/ivys/ivy-0.4.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.1", "0.4");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 95 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport in project ant-ivy by apache.

the class ResolveTest method testMultiConfs.

@Test
public void testMultiConfs() throws Exception {
    // mod 5.2 depends on mod5.1 conf B in its conf B and conf A in its conf A
    // mod5.1 conf B publishes art51B
    // mod5.1 conf A publishes art51A
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod5.2/ivy-2.0.xml"), getResolveOptions(new String[] { "B", "A" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org5", "mod5.2", "2.0");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    ModuleRevisionId depId = ModuleRevisionId.newInstance("org5", "mod5.1", "4.1");
    ConfigurationResolveReport crr = report.getConfigurationReport("A");
    assertNotNull(crr);
    assertEquals(1, crr.getDownloadReports(depId).length);
    File r = new File(cache, ResolveOptions.getDefaultResolveId(mrid.getModuleId()) + "-A.xml");
    assertTrue(r.exists());
    final boolean[] found = new boolean[] { false };
    SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
    saxParser.parse(r, new DefaultHandler() {

        @Override
        public void startElement(String uri, String localName, String qName, Attributes attributes) {
            if ("artifact".equals(qName) && "art51B".equals(attributes.getValue("name"))) {
                found[0] = true;
            }
        }
    });
    assertFalse(found[0]);
    assertTrue(getIvyFileInCache(depId).exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.1", "art51A", "jar", "jar").exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.1", "art51B", "jar", "jar").exists());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) Attributes(org.xml.sax.Attributes) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) SAXParser(javax.xml.parsers.SAXParser) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) DefaultHandler(org.xml.sax.helpers.DefaultHandler) Test(org.junit.Test)

Aggregations

ResolveReport (org.apache.ivy.core.report.ResolveReport)278 Test (org.junit.Test)259 File (java.io.File)253 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)218 JarFile (java.util.jar.JarFile)199 Ivy (org.apache.ivy.Ivy)102 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)101 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)94 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)15 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)13 BuildException (org.apache.tools.ant.BuildException)9 URL (java.net.URL)8 HashMap (java.util.HashMap)8 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)8 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)7 Artifact (org.apache.ivy.core.module.descriptor.Artifact)7 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)6