Search in sources :

Example 86 with ModuleDescriptor

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

the class RetrieveTest method testRetrieveWithSymlinksMass.

/**
 * This test is here to just test the deprecated {@code symlinkmass} option for retrieve task.
 * A version or two down the line, after 2.5 release, we can remove this test and the option
 * altogether.
 *
 * @throws Exception if something goes wrong
 */
@SuppressWarnings("deprecation")
@Test
public void testRetrieveWithSymlinksMass() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURI().toURL(), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(), getRetrieveOptions().setMakeSymlinksInMass(true).setDestArtifactPattern(pattern));
    assertLinkOrExists(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default"));
    pattern = "build/test/retrieve/[module]/[conf]/[type]s/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(), getRetrieveOptions().setMakeSymlinksInMass(true).setDestArtifactPattern(pattern));
    assertLinkOrExists(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default"));
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ResolveReport(org.apache.ivy.core.report.ResolveReport) File(java.io.File) Test(org.junit.Test)

Example 87 with ModuleDescriptor

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

the class RetrieveTest method testUnpack.

@Test
public void testUnpack() throws Exception {
    ResolveOptions roptions = 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, roptions);
    assertFalse(report.hasError());
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    String pattern = "build/test/retrieve/[organization]/[module]/[conf]/[type]s/[artifact]-[revision](.[ext])";
    ivy.retrieve(md.getModuleRevisionId(), getRetrieveOptions().setDestArtifactPattern(pattern));
    File dest = new File("build/test/retrieve/packaging/module2/default/jars/module2-1.0");
    assertTrue(dest.exists());
    assertTrue(dest.isDirectory());
    File[] jarContents = dest.listFiles();
    Arrays.sort(jarContents);
    assertEquals(new File(dest, "META-INF"), jarContents[0]);
    assertEquals(new File(dest, "test.txt"), jarContents[1]);
    assertEquals(new File(dest, "META-INF/MANIFEST.MF"), jarContents[0].listFiles()[0]);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ResolveReport(org.apache.ivy.core.report.ResolveReport) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 88 with ModuleDescriptor

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

the class RetrieveTest method testUnpackSync.

@Test
public void testUnpackSync() throws Exception {
    ResolveOptions roptions = 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, roptions);
    assertFalse(report.hasError());
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    String pattern = "build/test/retrieve/[organization]/[module]/[conf]/[type]s/[artifact]-[revision](.[ext])";
    ivy.retrieve(md.getModuleRevisionId(), getRetrieveOptions().setSync(true).setDestArtifactPattern(pattern));
    File dest = new File("build/test/retrieve/packaging/module2/default/jars/module2-1.0");
    assertTrue(dest.exists());
    assertTrue(dest.isDirectory());
    File[] jarContents = dest.listFiles();
    Arrays.sort(jarContents);
    assertEquals(new File(dest, "META-INF"), jarContents[0]);
    assertEquals(new File(dest, "test.txt"), jarContents[1]);
    assertEquals(new File(dest, "META-INF/MANIFEST.MF"), jarContents[0].listFiles()[0]);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ResolveReport(org.apache.ivy.core.report.ResolveReport) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 89 with ModuleDescriptor

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

the class PomModuleDescriptorParserTest method testOverriddenLicense.

/**
 * Tests that if a project explicitly specifies the licenses, then the licenses (if any) from
 * its parent pom aren't applied to the child project
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testOverriddenLicense() throws Exception {
    final IvySettings customIvySettings = createIvySettingsForParentLicenseTesting("test-parent-with-licenses.pom", "org.apache", "test-ivy-license-parent");
    final String pomFile = "test-project-with-overridden-licenses.pom";
    final ModuleDescriptor childModule = PomModuleDescriptorParser.getInstance().parseDescriptor(customIvySettings, this.getClass().getResource(pomFile), false);
    assertNotNull("Could not find " + pomFile, pomFile);
    final License[] licenses = childModule.getLicenses();
    assertNotNull("No licenses found in the module " + childModule, licenses);
    assertEquals("Unexpected number of licenses found in the module " + childModule, 1, licenses.length);
    assertEquals("Unexpected license name", "The Apache Software License, Version 2.0", licenses[0].getName());
    assertEquals("Unexpected license URL", "http://www.apache.org/licenses/LICENSE-2.0.txt", licenses[0].getUrl());
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) License(org.apache.ivy.core.module.descriptor.License) IvySettings(org.apache.ivy.core.settings.IvySettings) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Example 90 with ModuleDescriptor

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

the class PomModuleDescriptorParserTest method testLargePom.

@Test
public void testLargePom() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-large-pom.pom"), false);
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.myfaces", "myfaces", "6");
    assertEquals(mrid, md.getModuleRevisionId());
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Aggregations

ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)284 Test (org.junit.Test)233 File (java.io.File)143 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)114 ResolveReport (org.apache.ivy.core.report.ResolveReport)94 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)80 JarFile (java.util.jar.JarFile)76 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)76 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)69 IvySettings (org.apache.ivy.core.settings.IvySettings)60 XmlModuleDescriptorParserTest (org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest)44 Configuration (org.apache.ivy.core.module.descriptor.Configuration)30 Artifact (org.apache.ivy.core.module.descriptor.Artifact)28 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)27 IOException (java.io.IOException)24 ParseException (java.text.ParseException)23 Ivy (org.apache.ivy.Ivy)23 BufferedReader (java.io.BufferedReader)19 FileReader (java.io.FileReader)19 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)17