Search in sources :

Example 16 with DefaultModuleDescriptor

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

the class SortTest method testLatestIntegration.

/**
 * The dependency can ask for the latest integration. It should match whatever the version
 * declared in the modules to order.
 */
@Test
public void testLatestIntegration() {
    addDependency(md2, "md1", "latest.integration");
    addDependency(md3, "md2", "latest.integration");
    addDependency(md4, "md3", "latest.integration");
    settings.setVersionMatcher(new LatestVersionMatcher());
    DefaultModuleDescriptor[][] expectedOrder = new DefaultModuleDescriptor[][] { { md1, md2, md3, md4 } };
    for (List<ModuleDescriptor> toSort : getAllLists(md1, md3, md2, md4)) {
        assertSorted(expectedOrder, sortModuleDescriptors(toSort, nonMatchReporter));
    }
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) LatestVersionMatcher(org.apache.ivy.plugins.version.LatestVersionMatcher) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) Test(org.junit.Test)

Example 17 with DefaultModuleDescriptor

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

the class IvyEventFilterTest method setUp.

@Before
public void setUp() {
    md = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("foo", "bar", "1.0"), "integration", new Date());
    md2 = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("foo2", "bar", "1.0"), "integration", new Date());
    md3 = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("foo3", "baz", "1.0"), "integration", new Date());
    md4 = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("foo", "baz", "1.0"), "integration", new Date());
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) Date(java.util.Date) Before(org.junit.Before)

Example 18 with DefaultModuleDescriptor

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

the class OBRResolverTest method genericTestResolve.

private void genericTestResolve(String jarName, String conf, ModuleRevisionId[] expectedMrids, ModuleRevisionId[] expected2Mrids) throws Exception {
    JarInputStream jis = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/" + jarName));
    Manifest manifest = jis.getManifest();
    jis.close();
    BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
    bundleInfo.addArtifact(new BundleArtifact(false, new File("test/test-repo/bundlerepo/" + jarName).toURI(), null));
    DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(OSGiManifestParser.getInstance(), null, bundleInfo, profileProvider);
    ResolveReport resolveReport = ivy.resolve(md, new ResolveOptions().setConfs(new String[] { conf }).setOutputReport(false));
    assertFalse("resolve failed " + resolveReport.getAllProblemMessages(), resolveReport.hasError());
    Set<ModuleRevisionId> actual = new HashSet<>();
    for (Artifact artifact : resolveReport.getArtifacts()) {
        actual.add(artifact.getModuleRevisionId());
    }
    Set<ModuleRevisionId> expected = new HashSet<>(Arrays.asList(expectedMrids));
    if (expected2Mrids != null) {
        // in this use case, we have two choices, let's try the second one
        try {
            Set<ModuleRevisionId> expected2 = new HashSet<>(Arrays.asList(expected2Mrids));
            assertEquals(expected2, actual);
            // test passed
            return;
        } catch (AssertionError e) {
        // too bad, let's continue
        }
    }
    assertEquals(expected, actual);
}
Also used : JarInputStream(java.util.jar.JarInputStream) BundleArtifact(org.apache.ivy.osgi.core.BundleArtifact) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) Manifest(java.util.jar.Manifest) FileInputStream(java.io.FileInputStream) BundleArtifact(org.apache.ivy.osgi.core.BundleArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) ResolveReport(org.apache.ivy.core.report.ResolveReport) BundleInfo(org.apache.ivy.osgi.core.BundleInfo) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) File(java.io.File) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) HashSet(java.util.HashSet)

Example 19 with DefaultModuleDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor in project Saturn by vipshop.

the class IvyGetArtifact method getIvyfile.

private File getIvyfile(String org, String name, String rev, String[] confs, Set<Map<String, Object>> artifacts) throws IOException {
    File ivyfile;
    ivyfile = File.createTempFile("ivy", ".xml");
    ivyfile.deleteOnExit();
    DefaultModuleDescriptor md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance(org, name + "-caller", "working"));
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance(org, name, rev), false, false, true);
    if (artifacts != null && !artifacts.isEmpty()) {
        for (Map<String, Object> artifact : artifacts) {
            String artifactName = (String) artifact.get("name");
            String artifactType = (String) artifact.get("type");
            String artifactExt = (String) artifact.get("ext");
            URL artifactUrl = (URL) artifact.get("url");
            Map<?, ?> extraAttributes = (Map<?, ?>) artifact.get("extraAttributes");
            DefaultDependencyArtifactDescriptor dad = new DefaultDependencyArtifactDescriptor(dd, artifactName, artifactType, artifactExt, artifactUrl, extraAttributes);
            dd.addDependencyArtifact("default", dad);
        }
    }
    for (int i = 0; i < confs.length; i++) {
        dd.addDependencyConfiguration("default", confs[i]);
    }
    md.addDependency(dd);
    md.addExtraAttributeNamespace("m", "http://ant.apache.org/ivy/maven");
    XmlModuleDescriptorWriter.write(md, ivyfile);
    return ivyfile;
}
Also used : DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) DefaultDependencyArtifactDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyArtifactDescriptor) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) File(java.io.File) Map(java.util.Map) URL(java.net.URL)

Example 20 with DefaultModuleDescriptor

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

the class OBRResolverTest method genericTestFailingResolve.

private void genericTestFailingResolve(String jarName, String conf) throws Exception {
    JarInputStream jis = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/" + jarName));
    Manifest manifest = jis.getManifest();
    jis.close();
    BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
    bundleInfo.addArtifact(new BundleArtifact(false, new File("test/test-repo/bundlerepo/" + jarName).toURI(), null));
    DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(OSGiManifestParser.getInstance(), null, bundleInfo, manifest, profileProvider);
    ResolveReport resolveReport = ivy.resolve(md, new ResolveOptions().setConfs(new String[] { conf }).setOutputReport(false));
    assertTrue(resolveReport.hasError());
}
Also used : ResolveReport(org.apache.ivy.core.report.ResolveReport) BundleInfo(org.apache.ivy.osgi.core.BundleInfo) JarInputStream(java.util.jar.JarInputStream) BundleArtifact(org.apache.ivy.osgi.core.BundleArtifact) Manifest(java.util.jar.Manifest) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) File(java.io.File) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) FileInputStream(java.io.FileInputStream)

Aggregations

DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)30 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)17 Date (java.util.Date)10 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)9 File (java.io.File)7 Configuration (org.apache.ivy.core.module.descriptor.Configuration)7 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)6 ResolveReport (org.apache.ivy.core.report.ResolveReport)6 IvySettings (org.apache.ivy.core.settings.IvySettings)6 Test (org.junit.Test)6 MetadataArtifactDownloadReport (org.apache.ivy.core.report.MetadataArtifactDownloadReport)5 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)5 ParseException (java.text.ParseException)4 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)4 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)4 BufferedReader (java.io.BufferedReader)3 IOException (java.io.IOException)3 Map (java.util.Map)3 Artifact (org.apache.ivy.core.module.descriptor.Artifact)3 ModuleId (org.apache.ivy.core.module.id.ModuleId)3