use of aQute.bnd.version.Version in project bnd by bndtools.
the class PomRepositoryTest method testDependenciesWithVersionRanges.
public void testDependenciesWithVersionRanges() throws Exception {
BndPomRepository bpr = new BndPomRepository();
Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
w.setBase(tmp);
bpr.setRegistry(w);
Map<String, String> config = new HashMap<>();
config.put("revision", "com.mchange:mchange-commons-java:0.2.10");
config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
config.put("releaseUrls", "https://repo1.maven.org/maven2/");
config.put("name", "test");
bpr.setProperties(config);
List<String> list = bpr.list(null);
for (String bsn : list) {
SortedSet<Version> versions = bpr.versions(bsn);
assertEquals(1, versions.size());
Version v = versions.first();
switch(bsn) {
case "log4j:log4j":
assertEquals("1.2.14", v.toString());
break;
case "com.typesafe.config":
assertEquals("1.2.1", v.toString());
break;
case "com.mchange:mchange-commons-java":
assertEquals("0.2.10", v.toString());
break;
case "slf4j.api":
assertEquals("1.7.5", v.toString());
break;
default:
fail(bsn);
}
}
assertNotNull(list);
assertEquals(4, list.size());
}
use of aQute.bnd.version.Version in project bndtools by bndtools.
the class Auxiliary method doImport.
/*
* Parse the exports and see
*/
private boolean doImport(String exports) {
if (closed.get() || exports == null || exports.isEmpty())
return false;
Parameters out = new Parameters();
Parameters p = new Parameters(exports);
for (Entry<String, Attrs> e : p.entrySet()) {
Attrs attrs = e.getValue();
if (attrs == null)
continue;
String plugins = attrs.get("bnd-plugins");
if (plugins == null)
continue;
if (!(plugins.isEmpty() || "true".equalsIgnoreCase(plugins))) {
if (Verifier.isVersionRange(plugins)) {
VersionRange range = new VersionRange(plugins);
if (// TODO
!range.includes(About._3_0))
continue;
}
}
//
// Ok, matched
//
String v = attrs.getVersion();
if (v == null)
v = "0";
for (Iterator<String> i = attrs.keySet().iterator(); i.hasNext(); ) {
String key = i.next();
if (key.endsWith(":"))
i.remove();
}
if (Verifier.isVersion(v)) {
Version version = new Version(v);
attrs.put("version", new VersionRange(true, version, version, true).toString());
}
out.put(e.getKey(), attrs);
}
if (out.isEmpty())
return false;
String imports = out.toString();
synchronized (this) {
if (delta == null)
delta = new ArrayList<>();
delta.add(imports);
}
return true;
}
use of aQute.bnd.version.Version in project bndtools by bndtools.
the class RepositoryTargetLocation method resolveBundles.
@Override
protected TargetBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
resolveRepository();
try {
List<TargetBundle> bundles = new ArrayList<>();
List<String> bsns = repository.list("*");
monitor.beginTask("Resolving Bundles", bsns.size());
int i = 0;
for (String bsn : bsns) {
Version version = repository.versions(bsn).last();
File download = repository.get(bsn, version, new HashMap<String, String>(), new RepositoryPlugin.DownloadListener[] {});
try {
bundles.add(new TargetBundle(download));
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "Invalid plugin in repository: " + bsn + " @ " + getLocation(false), e));
}
if (monitor.isCanceled())
return null;
monitor.worked(++i);
}
monitor.done();
return bundles.toArray(new TargetBundle[0]);
} catch (CoreException e) {
throw e;
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, MESSAGE_UNABLE_TO_RESOLVE_BUNDLES, e));
}
}
use of aQute.bnd.version.Version in project bndtools by bndtools.
the class OSGiFrameworkContentProvider method refreshProviders.
private IStatus refreshProviders() {
List<IStatus> statuses = new ArrayList<>();
IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(Plugin.PLUGIN_ID, "osgiFrameworks");
for (IConfigurationElement element : configElements) {
String frameworkName = element.getAttribute("name");
String bsn = element.getAttribute("bsn");
URL iconUrl = null;
String iconPath = element.getAttribute("icon");
if (iconPath != null) {
Bundle contributorBundle = BundleUtils.findBundle(Plugin.getDefault().getBundleContext(), element.getContributor().getName(), null);
if (contributorBundle != null)
iconUrl = contributorBundle.getEntry(iconPath);
}
List<RepositoryPlugin> repositories;
try {
repositories = (workspace != null) ? workspace.getRepositories() : Collections.<RepositoryPlugin>emptyList();
} catch (Exception e) {
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, e.getMessage(), e);
}
for (RepositoryPlugin repo : repositories) {
try {
SortedSet<Version> versions = repo.versions(bsn);
if (versions != null)
for (Version version : versions) {
try {
File framework = repo.get(bsn, version, null);
if (framework != null)
frameworks.add(new OSGiFramework(frameworkName, bsn, version, iconUrl));
} catch (Exception e) {
String msg = String.format("Error finding repository entry for OSGi framework %s, version %s.", bsn, version.toString());
logger.logError(msg, e);
statuses.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, msg, e));
}
}
} catch (Exception e) {
String msg = String.format("Error searching repository for OSGi framework %s.", bsn);
logger.logError(msg, e);
statuses.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, msg, e));
}
}
}
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
structuredViewer.refresh(true);
}
});
if (statuses.size() > 0) {
return new MultiStatus(Plugin.PLUGIN_ID, IStatus.ERROR, statuses.toArray(new IStatus[0]), "Errors while refreshing OSGi framework providers.", null);
}
return Status.OK_STATUS;
}
use of aQute.bnd.version.Version in project bndtools by bndtools.
the class RepoDownloadJob method expandContentsInto.
private void expandContentsInto(RepositoryBundle bundle, List<RepositoryBundleVersion> rbvs) throws Exception {
RepositoryPlugin repo = bundle.getRepo();
SortedSet<Version> versions = repo.versions(bundle.getBsn());
if (versions != null) {
for (Version version : versions) {
RepositoryBundleVersion rbv = new RepositoryBundleVersion(bundle, version);
rbvs.add(rbv);
}
}
}
Aggregations