use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.
the class OSGiFrameworkContentProvider method inputChanged.
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
frameworks.clear();
Workspace workspace = (Workspace) newInput;
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) {
throw Exceptions.duck(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) {
logger.logError(String.format("Error finding repository entry for OSGi framework %s, version %s.", bsn, version.toString()), e);
}
}
} catch (Exception e) {
logger.logError(String.format("Error searching repository for OSGi framework %s.", bsn), e);
}
}
}
}
use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.
the class OSGiRepositoryTest method testPollingWithFile.
public void testPollingWithFile() throws Exception {
try (OSGiRepository r = new OSGiRepository()) {
Map<String, String> map = new HashMap<>();
map.put("locations", IO.getFile(remote, "minir5.xml").toURI().toString());
map.put("cache", cache.getPath());
map.put("max.stale", "10000");
map.put("name", "test");
map.put("poll.time", "1");
r.setProperties(map);
Processor p = new Processor();
HttpClient httpClient = new HttpClient();
httpClient.setCache(cache);
httpClient.setRegistry(p);
p.addBasicPlugin(httpClient);
p.setBase(ws);
p.addBasicPlugin(Workspace.createStandaloneWorkspace(p, ws.toURI()));
r.setRegistry(p);
final AtomicReference<RepositoryPlugin> refreshed = new AtomicReference<>();
p.addBasicPlugin(new RepositoryListenerPlugin() {
@Override
public void repositoryRefreshed(RepositoryPlugin repository) {
refreshed.set(repository);
}
@Override
public void repositoriesRefreshed() {
// TODO Auto-generated method stub
}
@Override
public void bundleRemoved(RepositoryPlugin repository, Jar jar, File file) {
// TODO Auto-generated method stub
}
@Override
public void bundleAdded(RepositoryPlugin repository, Jar jar, File file) {
// TODO Auto-generated method stub
}
});
File file = r.get("dummybundle", new Version("0"), null);
assertNotNull(file);
Thread.sleep(3000);
assertEquals(null, refreshed.get());
System.out.println("1");
// update the index file
File index = IO.getFile(remote, "minir5.xml");
long time = index.lastModified();
do {
Thread.sleep(1000);
String s = IO.collect(index);
// change the sha
s += " ";
IO.store(s, index);
System.out.println(index.lastModified());
} while (index.lastModified() == time);
System.out.println("2 ");
// give the poller a chance
Thread.sleep(3000);
System.out.println("3 ");
assertEquals(r, refreshed.get());
assertEquals("test [stale]", r.title(new Object[0]));
System.out.println(r.tooltip(new Object[0]));
}
}
use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.
the class ExportMojo method export.
private void export(File runFile, FileSetRepository fileSetRepository) throws Exception {
if (!runFile.exists()) {
logger.error("Could not find bnd run file {}", runFile);
errors++;
return;
}
String bndrun = getNamePart(runFile);
File temporaryDir = new File(targetDir, "tmp/export/" + bndrun);
File cnf = new File(temporaryDir, Workspace.CNFDIR);
IO.mkdirs(cnf);
try (Bndrun run = Bndrun.createBndrun(null, runFile)) {
run.setBase(temporaryDir);
Workspace workspace = run.getWorkspace();
workspace.setBuildDir(cnf);
workspace.setOffline(session.getSettings().isOffline());
workspace.addBasicPlugin(fileSetRepository);
for (RepositoryPlugin repo : workspace.getRepositories()) {
repo.list(null);
}
run.getInfo(workspace);
report(run);
if (!run.isOk()) {
return;
}
if (resolve) {
try {
String runBundles = run.resolve(failOnChanges, false);
if (!run.isOk()) {
return;
}
run.setProperty(Constants.RUNBUNDLES, runBundles);
} catch (ResolutionException re) {
logger.error("Unresolved requirements: {}", ResolveProcess.format(re.getUnresolvedRequirements()));
throw re;
} finally {
report(run);
}
}
try {
if (bundlesOnly) {
File runbundlesDir = new File(targetDir, "export/" + bndrun);
IO.mkdirs(runbundlesDir);
run.exportRunbundles(null, runbundlesDir);
} else {
File executableJar = new File(targetDir, bndrun + ".jar");
run.export(null, false, executableJar);
}
} finally {
report(run);
}
}
}
use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.
the class ResolverMojo method resolve.
private void resolve(File runFile, FileSetRepository fileSetRepository) throws Exception {
if (!runFile.exists()) {
logger.error("Could not find bnd run file {}", runFile);
errors++;
return;
}
String bndrun = getNamePart(runFile);
File temporaryDir = new File(targetDir, "tmp/resolve/" + bndrun);
File cnf = new File(temporaryDir, Workspace.CNFDIR);
IO.mkdirs(cnf);
try (Bndrun run = Bndrun.createBndrun(null, runFile)) {
run.setBase(temporaryDir);
Workspace workspace = run.getWorkspace();
workspace.setBuildDir(cnf);
workspace.setOffline(session.getSettings().isOffline());
workspace.addBasicPlugin(fileSetRepository);
for (RepositoryPlugin repo : workspace.getRepositories()) {
repo.list(null);
}
run.getInfo(workspace);
report(run);
if (!run.isOk()) {
return;
}
try {
run.resolve(failOnChanges, true);
} catch (ResolutionException re) {
logger.error("Unresolved requirements: {}", ResolveProcess.format(re.getUnresolvedRequirements()));
throw re;
} finally {
report(run);
}
}
}
use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.
the class AddFilesToRepositoryWizard method addPages.
@Override
public void addPages() {
if (repository == null) {
addPage(repoSelectionPage);
repoSelectionPage.addPropertyChangeListener(LocalRepositorySelectionPage.PROP_SELECTED_REPO, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
repository = (RepositoryPlugin) evt.getNewValue();
}
});
}
addPage(fileSelectionPage);
}
Aggregations