use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.
the class OSGiRepositoryTest method testPolling.
public void testPolling(Workspace workspace) throws Exception {
try (OSGiRepository r = new OSGiRepository()) {
Map<String, String> map = new HashMap<>();
map.put("locations", fnx.getBaseURI("/repo/minir5.xml").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);
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);
// not stale, default name
assertNull(r.title(new Object[0]));
System.out.println("1");
Thread.sleep(3000);
System.out.println("2");
assertEquals(null, refreshed.get());
System.out.println("3");
// update the index file
File index = IO.getFile(remote, "minir5.xml");
long time = index.lastModified();
String s = IO.collect(index);
// change the sha
s += " ";
IO.store(s, index);
System.out.println("5 " + index + " " + (index.lastModified() - time));
// give the poller a chance
Thread.sleep(3000);
System.out.println("6");
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 bnd method _release.
/**
* Release the project
*
* @throws Exception
*/
@Description("Release this project")
public void _release(releaseOptions options) throws Exception {
Set<Project> projects = new LinkedHashSet<Project>();
Workspace ws = Workspace.findWorkspace(getBase());
if (ws == null) {
error("Workspace option was specified but cannot find a workspace from %s", getBase());
return;
}
if (options.workspace()) {
projects.addAll(ws.getAllProjects());
}
Project project = getProject(options.project());
if (project != null) {
projects.add(project);
}
if (projects.isEmpty()) {
error("Cannot find any projects");
return;
}
String repo = options.repo();
if (repo != null) {
RepositoryPlugin repository = ws.getRepository(repo);
if (repository == null) {
error("No such release repo %s%nFound:%n%s", repository, Strings.join("\n", ws.getRepositories()));
}
}
for (Project p : projects) {
if (repo != null) {
p.setProperty(Constants.RELEASEREPO, repo);
}
p.release(options.test());
}
getInfo(project);
}
use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.
the class bnd method _bsn2url.
public void _bsn2url(Bsn2UrlOptions opts) throws Exception {
Project p = getProject(opts.project());
if (p == null) {
error("You need to be in a project or specify the project with -p/--project");
return;
}
MultiMap<String, Version> revisions = new MultiMap<String, Version>();
for (RepositoryPlugin repo : p.getPlugins(RepositoryPlugin.class)) {
if (!(repo instanceof InfoRepository))
continue;
for (String bsn : repo.list(null)) {
revisions.addAll(bsn, repo.versions(bsn));
}
}
for (List<Version> versions : revisions.values()) {
Collections.sort(versions, Collections.reverseOrder());
}
List<String> files = opts._arguments();
for (String f : files) {
try (BufferedReader r = IO.reader(getFile(f))) {
String line;
nextLine: while ((line = r.readLine()) != null) {
Matcher matcher = LINE_P.matcher(line);
if (!matcher.matches())
continue nextLine;
line = matcher.group(1);
Parameters bundles = new Parameters(line, this);
for (Map.Entry<String, Attrs> entry : bundles.entrySet()) {
String bsn = entry.getKey();
VersionRange range = new VersionRange(entry.getValue().getVersion());
List<Version> versions = revisions.get(bsn);
if (versions == null) {
error("No for versions for %s", bsn);
break nextLine;
}
for (Version version : versions) {
if (range.includes(version)) {
for (RepositoryPlugin repo : p.getPlugins(RepositoryPlugin.class)) {
if (!(repo instanceof InfoRepository))
continue;
InfoRepository rp = (InfoRepository) repo;
ResourceDescriptor descriptor = rp.getDescriptor(bsn, version);
if (descriptor == null) {
error("Found bundle, but no descriptor %s;version=%s", bsn, version);
return;
}
out.println(descriptor.url + " #" + descriptor.bsn + ";version=" + descriptor.version);
}
}
}
}
}
} catch (Exception e) {
error("failed to create url list from file %s : %s", f, e);
}
}
}
use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.
the class Workspace method _repodigests.
/**
* Return the repository signature digests. These digests are a unique id
* for the contents of the repository
*/
public Object _repodigests(String[] args) throws Exception {
Macro.verifyCommand(args, "${repodigests;[;<repo names>]...}, get the repository digests", null, 1, 10000);
List<RepositoryPlugin> repos = getRepositories();
if (args.length > 1) {
repos: for (Iterator<RepositoryPlugin> it = repos.iterator(); it.hasNext(); ) {
String name = it.next().getName();
for (int i = 1; i < args.length; i++) {
if (name.equals(args[i])) {
continue repos;
}
}
it.remove();
}
}
List<String> digests = new ArrayList<String>();
for (RepositoryPlugin repo : repos) {
try {
if (repo instanceof RepositoryDigest) {
byte[] digest = ((RepositoryDigest) repo).getDigest();
digests.add(Hex.toHexString(digest));
} else {
if (args.length != 1)
error("Specified repo %s for ${repodigests} was named but it is not found", repo.getName());
}
} catch (Exception e) {
if (args.length != 1)
error("Specified repo %s for digests is not found", repo.getName());
// else Ignore
}
}
return join(digests, ",");
}
use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.
the class AetherRepsitoryTests method testSourceLookup.
public void testSourceLookup() throws Exception {
RepositoryPlugin repo = createRepo();
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("version", "2.5");
attrs.put("bsn", "javax.servlet:servlet-api");
File file = repo.get("servlet-api.source", new Version(2, 5, 0), attrs, listener);
assertTrue(file.exists());
assertEquals("servlet-api-2.5-sources.jar", file.getName());
}
Aggregations