use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class SortTest method addDependency.
private DependencyDescriptor addDependency(DefaultModuleDescriptor parent, String moduleName, String revision) {
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", moduleName, revision);
DependencyDescriptor depDescr = new DefaultDependencyDescriptor(parent, mrid, false, false, true);
parent.addDependency(depDescr);
return depDescr;
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class AggregatedOSGiResolverTest method genericTestResolveDownload.
private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid) throws ParseException {
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
DownloadReport report = resolver.download(new Artifact[] { artifact }, new DownloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
// test to ask to download again, should use cache
report = resolver.download(new Artifact[] { artifact }, new DownloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class TestPerformance method generateModules.
private void generateModules(int nbModules, int minDependencies, int maxDependencies, int minVersions, int maxVersions) throws IOException {
int nb = 0;
int curDep = 1;
int varDeps = maxDependencies - minDependencies;
int varVersions = maxVersions - minVersions;
Random r = new Random(System.currentTimeMillis());
while (nb < nbModules) {
int deps = minDependencies + r.nextInt(varDeps + 1);
int versions = minVersions + r.nextInt(varVersions + 1);
int prevCurDep = curDep;
for (int ver = 0; ver < versions; ver++) {
DefaultModuleDescriptor md = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("apache", "mod" + nb, "1." + ver), "integration", new Date());
curDep = prevCurDep;
for (int i = 0; i < deps && curDep < nbModules; i++) {
int d;
if (i % 2 == 1) {
d = nb + i;
if (d >= prevCurDep) {
d = curDep;
curDep++;
}
} else {
d = curDep;
curDep++;
}
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance("apache", "mod" + d, "latest.integration"), false, false, true);
dd.addDependencyConfiguration("default", "default");
md.addDependency(dd);
}
XmlModuleDescriptorWriter.write(md, new File("build/test/perf/mod" + nb + "/ivy-1." + ver + ".xml"));
FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), new File("build/test/perf/mod" + nb + "/mod" + nb + "-1." + ver + ".jar"), null);
}
nb++;
}
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class AbstractOSGiResolver method buildResolvedCapabilityMd.
private MDResolvedResource buildResolvedCapabilityMd(DependencyDescriptor dd, ModuleDescriptor md) {
String org = dd.getDependencyRevisionId().getOrganisation();
String name = dd.getDependencyRevisionId().getName();
String rev = md.getExtraInfoContentByTagName(BundleInfoAdapter.EXTRA_INFO_EXPORT_PREFIX + name);
ModuleRevisionId capabilityRev = ModuleRevisionId.newInstance(org, name, rev, Collections.singletonMap(CAPABILITY_EXTRA_ATTR, md.getModuleRevisionId().toString()));
DefaultModuleDescriptor capabilityMd = new DefaultModuleDescriptor(capabilityRev, getSettings().getStatusManager().getDefaultStatus(), new Date());
String useConf = BundleInfoAdapter.CONF_USE_PREFIX + dd.getDependencyRevisionId().getName();
capabilityMd.addConfiguration(BundleInfoAdapter.CONF_DEFAULT);
capabilityMd.addConfiguration(BundleInfoAdapter.CONF_OPTIONAL);
capabilityMd.addConfiguration(BundleInfoAdapter.CONF_TRANSITIVE_OPTIONAL);
capabilityMd.addConfiguration(new Configuration(useConf));
DefaultDependencyDescriptor capabilityDD = new DefaultDependencyDescriptor(md.getModuleRevisionId(), false);
capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_DEFAULT, BundleInfoAdapter.CONF_NAME_DEFAULT);
capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_OPTIONAL, BundleInfoAdapter.CONF_NAME_OPTIONAL);
capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL, BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL);
capabilityDD.addDependencyConfiguration(useConf, useConf);
capabilityMd.addDependency(capabilityDD);
MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null);
report.setDownloadStatus(DownloadStatus.NO);
report.setSearched(true);
ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, capabilityMd, report);
return new MDResolvedResource(null, capabilityMd.getRevision(), rmr);
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class BundleInfoAdapter method requirementAsDependency.
private static void requirementAsDependency(DefaultModuleDescriptor md, BundleInfo bundleInfo, Set<String> exportedPkgNames) {
for (BundleRequirement requirement : bundleInfo.getRequirements()) {
String type = requirement.getType();
String name = requirement.getName();
if (BundleInfo.PACKAGE_TYPE.equals(type) && exportedPkgNames.contains(name)) {
// don't declare package exported by the current bundle
continue;
}
if (BundleInfo.EXECUTION_ENVIRONMENT_TYPE.equals(type)) {
// execution environment are handled elsewhere
continue;
}
ModuleRevisionId ddmrid = asMrid(type, name, requirement.getVersion());
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ddmrid, false);
String conf = CONF_NAME_DEFAULT;
if (BundleInfo.PACKAGE_TYPE.equals(type)) {
// declare the configuration for the package
conf = CONF_USE_PREFIX + name;
md.addConfiguration(new Configuration(CONF_USE_PREFIX + name, PUBLIC, "Exported package " + name, new String[] { CONF_NAME_DEFAULT }, true, null));
dd.addDependencyConfiguration(conf, conf);
}
if ("optional".equals(requirement.getResolution())) {
dd.addDependencyConfiguration(CONF_NAME_OPTIONAL, conf);
dd.addDependencyConfiguration(CONF_NAME_TRANSITIVE_OPTIONAL, CONF_NAME_TRANSITIVE_OPTIONAL);
} else {
dd.addDependencyConfiguration(CONF_NAME_DEFAULT, conf);
}
md.addDependency(dd);
}
}
Aggregations