Search in sources :

Example 41 with ConfigurationResolveReport

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

the class ResolveTest method testResolveMultipleExtends2.

@Test
public void testResolveMultipleExtends2() throws Exception {
    // same as before, except that mod6.2 depends on mod1.2 2.1 extension->default
    // so mod1.2 2.0 should be evicted in conf extension
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org6/mod6.2/ivys/ivy-0.4.xml"), getResolveOptions(new String[] { "default", "extension" }));
    assertNotNull(report);
    assertFalse(report.hasError());
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.2", "0.4");
    assertEquals(mrid, md.getModuleRevisionId());
    ConfigurationResolveReport crr = report.getConfigurationReport("default");
    assertNotNull(crr);
    assertEquals(2, crr.getArtifactsNumber());
    IvyNode node = crr.getDependency(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"));
    assertNotNull(node);
    assertFalse(node.isEvicted("default"));
    crr = report.getConfigurationReport("extension");
    assertNotNull(crr);
    assertEquals(2, crr.getArtifactsNumber());
    node = crr.getDependency(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"));
    assertNotNull(node);
    assertTrue(node.isEvicted("extension"));
    node = crr.getDependency(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1"));
    assertNotNull(node);
    assertFalse(node.isEvicted("extension"));
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org6", "mod6.1", "0.4")).exists());
    assertTrue(getArchiveFileInCache("org6", "mod6.1", "0.4", "mod6.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) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 42 with ConfigurationResolveReport

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

the class LatestCompatibleConflictManagerTest method resolveAndAssert.

private void resolveAndAssert(String mrid, String expectedModuleSet) throws ParseException, IOException {
    ResolveReport report = fixture.resolve(mrid);
    assertFalse(report.hasError());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    TestHelper.assertModuleRevisionIds(expectedModuleSet, defaultReport.getModuleRevisionIds());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport)

Example 43 with ConfigurationResolveReport

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

the class LatestConflictManagerTest method testLatestTime2.

@Test
public void testLatestTime2() throws Exception {
    ivy = new Ivy();
    ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest-time.xml"));
    ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);
    // set timestamps, because svn is not preserving this information,
    // and the latest time strategy is relying on it
    long time = System.currentTimeMillis() - 10000;
    new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").setLastModified(time);
    new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.2.jar").setLastModified(time + 2000);
    ResolveReport report = ivy.resolve(LatestConflictManagerTest.class.getResource("ivy-latest-time-2.xml"), getResolveOptions());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
        if (mrid.getName().equals("mod1.1")) {
            assertEquals("1.0", mrid.getRevision());
        } else if (mrid.getName().equals("mod1.2")) {
            assertEquals("2.2", mrid.getRevision());
        }
    }
}
Also used : 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) Ivy(org.apache.ivy.Ivy) File(java.io.File) Test(org.junit.Test)

Example 44 with ConfigurationResolveReport

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

the class LatestConflictManagerTest method testLatestTime1.

/**
 * Test case for IVY-407.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-407">IVY-407</a>
 */
@Test
public void testLatestTime1() throws Exception {
    ivy = new Ivy();
    ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest-time.xml"));
    ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);
    // set timestamps, because svn is not preserving this information,
    // and the latest time strategy is relying on it
    long time = System.currentTimeMillis() - 10000;
    new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").setLastModified(time);
    new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.2.jar").setLastModified(time + 2000);
    ResolveReport report = ivy.resolve(LatestConflictManagerTest.class.getResource("ivy-latest-time-1.xml"), getResolveOptions());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
        if (mrid.getName().equals("mod1.1")) {
            assertEquals("1.0", mrid.getRevision());
        } else if (mrid.getName().equals("mod1.2")) {
            assertEquals("2.2", mrid.getRevision());
        }
    }
}
Also used : 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) Ivy(org.apache.ivy.Ivy) File(java.io.File) Test(org.junit.Test)

Example 45 with ConfigurationResolveReport

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

the class IvyCacheTask method getAllArtifactReports.

private Collection<ArtifactDownloadReport> getAllArtifactReports() throws ParseException {
    String[] confs = splitToArray(getConf());
    Collection<ArtifactDownloadReport> all = new LinkedHashSet<>();
    ResolveReport report = getResolvedReport();
    if (report != null) {
        Message.debug("using internal report instance to get artifacts list");
        for (String conf : confs) {
            ConfigurationResolveReport configurationReport = report.getConfigurationReport(conf);
            if (configurationReport == null) {
                throw new BuildException("bad confs provided: " + conf + " not found among " + Arrays.asList(report.getConfigurations()));
            }
            for (ModuleRevisionId revId : configurationReport.getModuleRevisionIds()) {
                all.addAll(Arrays.asList(configurationReport.getDownloadReports(revId)));
            }
        }
    } else {
        Message.debug("using stored report to get artifacts list");
        XmlReportParser parser = new XmlReportParser();
        ResolutionCacheManager cacheMgr = getIvyInstance().getResolutionCacheManager();
        String resolvedId = getResolveId();
        if (resolvedId == null) {
            resolvedId = ResolveOptions.getDefaultResolveId(getResolvedModuleId());
        }
        for (String conf : confs) {
            File reportFile = cacheMgr.getConfigurationResolveReportInCache(resolvedId, conf);
            parser.parse(reportFile);
            all.addAll(Arrays.asList(parser.getArtifactReports()));
        }
    }
    return all;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) XmlReportParser(org.apache.ivy.plugins.report.XmlReportParser) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ResolutionCacheManager(org.apache.ivy.core.cache.ResolutionCacheManager) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) BuildException(org.apache.tools.ant.BuildException) File(java.io.File)

Aggregations

ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)45 ResolveReport (org.apache.ivy.core.report.ResolveReport)43 File (java.io.File)40 Test (org.junit.Test)40 JarFile (java.util.jar.JarFile)34 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)27 Ivy (org.apache.ivy.Ivy)16 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)12 SAXParser (javax.xml.parsers.SAXParser)4 Attributes (org.xml.sax.Attributes)4 DefaultHandler (org.xml.sax.helpers.DefaultHandler)4 HashMap (java.util.HashMap)3 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)3 ArrayList (java.util.ArrayList)2 LinkedHashSet (java.util.LinkedHashSet)2 ParseException (java.text.ParseException)1 Date (java.util.Date)1 IvyContext (org.apache.ivy.core.IvyContext)1 ResolutionCacheManager (org.apache.ivy.core.cache.ResolutionCacheManager)1 EndResolveEvent (org.apache.ivy.core.event.resolve.EndResolveEvent)1