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));
}
}
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());
}
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);
}
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;
}
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());
}
Aggregations