Search in sources :

Example 71 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class ResolveTest method testExtraAttributes4.

/**
 * Second test case for IVY-745.ยจ
 * Now we disable consistency checking, everything must work fine.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-745">IVY-745</a>
 */
@Test
public void testExtraAttributes4() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/extra-attributes/ivysettings.xml"));
    ivy.getSettings().setDefaultCache(cache);
    ((FileSystemResolver) ivy.getSettings().getResolver("default")).setCheckconsistency(false);
    ivy.getSettings().validate();
    ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att3.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(false));
    assertFalse(report.hasError());
    assertTrue(new File(cache, "apache/mymodule/task2/1749/ivy.xml").exists());
    assertTrue(new File(cache, "apache/mymodule/task2/1749/ivy.xml.original").exists());
    assertTrue(new File(cache, "apache/mymodule/task2/1749/mymodule-windows.jar").exists());
    assertTrue(new File(cache, "apache/mymodule/task2/1749/mymodule-linux.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) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Test(org.junit.Test)

Example 72 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class ResolveTest method testForceLocal.

@Test
public void testForceLocal() throws Exception {
    // mod2.1 depends on mod1.1 which depends on mod1.2
    // a local build for mod1.2 is available
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/ivysettings-local.xml"));
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    // 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", "local-20080708091023")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "local-20080708091023", "mod1.2", "jar", "jar").exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-A", "jar", "jar").exists());
    assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
    assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "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 73 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class ResolveTest method testResolveRequiresDescriptor.

@Test
public void testResolveRequiresDescriptor() throws Exception {
    // mod1.1 depends on mod1.2, mod1.2 has no ivy file
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/ivysettings.xml"));
    ((FileSystemResolver) ivy.getSettings().getResolver("1")).setDescriptor(FileSystemResolver.DESCRIPTOR_REQUIRED);
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    assertTrue(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) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Test(org.junit.Test)

Example 74 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class DefaultRepositoryCacheManagerTest method setUp.

@Before
public void setUp() throws Exception {
    File f = File.createTempFile("ivycache", ".dir");
    ivy = new Ivy();
    ivy.configureDefault();
    ivy.getLoggerEngine().setDefaultLogger(new DefaultMessageLogger(Message.MSG_DEBUG));
    IvyContext.pushNewContext().setIvy(ivy);
    IvySettings settings = ivy.getSettings();
    // we want to use the file as a directory, so we delete the file itself
    f.delete();
    cacheManager = new DefaultRepositoryCacheManager();
    cacheManager.setSettings(settings);
    cacheManager.setBasedir(f);
    artifact = createArtifact("org", "module", "rev", "name", "type", "ext");
    Artifact originArtifact = createArtifact("org", "module", "rev", "name", "pom.original", "pom");
    origin = new ArtifactOrigin(originArtifact, true, "file:/some/where.pom");
    cacheManager.saveArtifactOrigin(originArtifact, origin);
    cacheManager.saveArtifactOrigin(artifact, origin);
}
Also used : DefaultMessageLogger(org.apache.ivy.util.DefaultMessageLogger) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) Ivy(org.apache.ivy.Ivy) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Before(org.junit.Before)

Example 75 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class InstallTest method testSimpleWithoutDefaultResolver.

@Test
public void testSimpleWithoutDefaultResolver() throws Exception {
    Ivy ivy = Ivy.newInstance();
    ivy.configure(new File("test/repositories/ivysettings-nodefaultresolver.xml"));
    ivy.install(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"), "test", "install", new InstallOptions());
    assertTrue(new File("build/test/install/org1/mod1.2/ivy-2.0.xml").exists());
    assertTrue(new File("build/test/install/org1/mod1.2/mod1.2-2.0.jar").exists());
}
Also used : Ivy(org.apache.ivy.Ivy) File(java.io.File) Test(org.junit.Test)

Aggregations

Ivy (org.apache.ivy.Ivy)169 File (java.io.File)147 Test (org.junit.Test)137 ResolveReport (org.apache.ivy.core.report.ResolveReport)102 JarFile (java.util.jar.JarFile)100 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)97 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)40 IvySettings (org.apache.ivy.core.settings.IvySettings)26 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)23 BuildException (org.apache.tools.ant.BuildException)17 Before (org.junit.Before)12 HashMap (java.util.HashMap)9 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)8 RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)6 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)6 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)5 ModuleId (org.apache.ivy.core.module.id.ModuleId)5 IOException (java.io.IOException)4 ParseException (java.text.ParseException)4 Date (java.util.Date)4