Search in sources :

Example 61 with ResolveReport

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

the class ResolveTest method testIVY1333.

/**
 * Test case for IVY-1333.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1333">IVY-1333</a>
 */
@Test
public void testIVY1333() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/IVY-1333/ivysettings.xml"));
    ivy.getSettings().setDefaultCache(cache);
    ResolveReport rr = ivy.resolve(new File("test/repositories/IVY-1333/ivy.xml"), getResolveOptions(new String[] { "*" }));
    ConfigurationResolveReport crr = rr.getConfigurationReport("default");
    Set<ModuleRevisionId> modRevIds = crr.getModuleRevisionIds();
    assertEquals(3, modRevIds.size());
    assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "dep1", "1.0")));
    assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "dep2", "1.0")));
    Map<String, String> extra = new HashMap<>();
    extra.put("o:a", "58701");
    assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "badArtifact", "1.0.0.m4", extra)));
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) HashMap(java.util.HashMap) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 62 with ResolveReport

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

the class ResolveTest method testTransitiveConfMapping.

/**
 * Test case for IVY-168.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-168">IVY-168</a>
 */
@Test
public void testTransitiveConfMapping() throws Exception {
    // mod13.3 depends on mod13.2 which depends on mod13.1
    // each module has two confs: j2ee and compile
    // each module only publishes one artifact in conf compile
    // each module has the following conf mapping on its dependencies: *->@
    // moreover, mod13.1 depends on mod1.2 in with the following conf mapping: compile->default
    // thus conf j2ee should be empty for each modules
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod13.3/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    assertEquals(3, report.getConfigurationReport("compile").getArtifactsNumber());
    assertEquals(0, report.getConfigurationReport("j2ee").getArtifactsNumber());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 63 with ResolveReport

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

the class ResolveTest method testExtraAttributesMultipleDependenciesHang2.

@Test
public void testExtraAttributesMultipleDependenciesHang2() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/extra-attributes-multipledependencies/ivysettings-filerepo-attribs.xml"));
    ivy.getSettings().setDefaultCache(cache);
    ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att-multipledependencies2.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(false));
    assertFalse(report.hasError());
}
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 64 with ResolveReport

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

the class ResolveTest method testUnpack.

@Test
public void testUnpack() throws Exception {
    ResolveOptions options = getResolveOptions(new String[] { "*" });
    URL url = new File("test/repositories/1/packaging/module1/ivys/ivy-1.0.xml").toURI().toURL();
    // normal resolve, the file goes in the cache
    ResolveReport report = ivy.resolve(url, options);
    assertFalse(report.hasError());
    ArtifactDownloadReport adr = report.getAllArtifactsReports()[0];
    File cacheDir = ivy.getSettings().getDefaultRepositoryCacheBasedir();
    assertEquals(new File(cacheDir, "packaging/module2/jars/module2-1.0.jar"), adr.getLocalFile());
    assertEquals(new File(cacheDir, "packaging/module2/jar_unpackeds/module2-1.0"), adr.getUnpackedLocalFile());
    File[] jarContents = adr.getUnpackedLocalFile().listFiles();
    Arrays.sort(jarContents);
    assertEquals(new File(adr.getUnpackedLocalFile(), "META-INF"), jarContents[0]);
    assertEquals(new File(adr.getUnpackedLocalFile(), "test.txt"), jarContents[1]);
    assertEquals(new File(adr.getUnpackedLocalFile(), "META-INF/MANIFEST.MF"), jarContents[0].listFiles()[0]);
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) JarFile(java.util.jar.JarFile) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 65 with ResolveReport

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

the class ResolveTest method testResolveMultipleConfsWithLatest.

/**
 * Test case for IVY-188.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-188">IVY-188</a>
 */
@Test
public void testResolveMultipleConfsWithLatest() throws Exception {
    // mod6.2 has two confs compile and run
    // depends on mod6.1 in conf (compile->default)
    // depends on mod1.2 latest (which is 2.2) in conf (run->default)
    // mod6.1
    // depends on mod1.2 2.2
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org6/mod6.2/ivys/ivy-0.6.xml"), getResolveOptions(new String[] { "compile", "run" }));
    assertNotNull(report);
    assertFalse(report.hasError());
    ConfigurationResolveReport crr = report.getConfigurationReport("compile");
    assertNotNull(crr);
    assertEquals(2, crr.getArtifactsNumber());
    crr = report.getConfigurationReport("run");
    assertNotNull(crr);
    assertEquals(1, crr.getArtifactsNumber());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.2")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) 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