public void copy(RepositoryPlugin source, Instructions filter, RepositoryPlugin destination) throws Exception { assert source != null; assert destination != null; logger.info("copy from repo {} to {} with filter {}", source, destination, filter); for (String bsn : source.list(null)) { for (Version version : source.versions(bsn)) { if (filter == null || filter.matches(bsn)) { logger.info("copy {}:{}", bsn, version); File file = source.get(bsn, version, null); if (file.getName() .endsWith(".jar")) { try (InputStream in = IO.stream(file)) { PutOptions po = new PutOptions(); po.bsn = bsn; po.context = null; po.type = "bundle"; po.version = version; PutResult put = destination.put(in, po); } catch (Exception e) { logger.error("Failed to copy {}-{}", e, bsn, version); error("Failed to copy %s:%s from %s to %s, error: %s", bsn, version, source, destination, e); } } } } } }
public static Element getTree(RepositoryPlugin repo) throws Exception { List<Element> programs = new ArrayList<Element>(); for (String bsn : repo.list(null)) { List<Element> versions = new ArrayList<Element>(); for (Version version : repo.versions(bsn)) { versions.add(new Element(Type.VERSION, version.toString())); } programs.add(new Element(Type.PROGRAM, bsn, versions, Delta.MINOR, Delta.MAJOR, null)); } return new Element(Type.REPO, repo.getName(), programs, Delta.MINOR, Delta.MAJOR, repo.getLocation()); }
@Description("List the current repositories") public void _repos(@SuppressWarnings("unused") reposOptions opts) { int n = 1; for (RepositoryPlugin repo : repos) { String location = ""; try { location = repo.getLocation(); } catch (Throwable e) { // Ignore } bnd.out.printf("%03d: %-20s %4s %-20s %s%n", n++, repo.getName(), repo.canWrite() ? "r/w" : "r/o", Descriptors.getShortName(repo.getClass().getName()), location); } }
RepositoryPlugin getReleaseRepo(String releaserepo) { String name = releaserepo == null ? name = getProperty(RELEASEREPO) : releaserepo; List<RepositoryPlugin> plugins = getPlugins(RepositoryPlugin.class); for (RepositoryPlugin plugin : plugins) { if (!plugin.canWrite()) continue; if (name == null) return plugin; if (name.equals(plugin.getName())) return plugin; } return null; }
private RepositoryPlugin findRepo(String name) { for (RepositoryPlugin repo : repos) { if (repo.getName().equals(name)) return repo; } return null; }
private File getBaselineFromRepo(boolean fallback) throws Exception { String repoName = getProperty(Constants.BASELINEREPO); if (repoName == null && !fallback) return null; if (repoName == null) { repoName = getProperty(Constants.RELEASEREPO); if (repoName == null) { return null; } } List<RepositoryPlugin> repos = getPlugins(RepositoryPlugin.class); for (RepositoryPlugin repo : repos) { if (repoName.equals(repo.getName())) { SortedSet<Version> versions = repo.versions(getBsn()); if (!versions.isEmpty()) { return repo.get(getBsn(), versions.last(), null); } break; } } return null; }
private URI releaseRepo(RepositoryPlugin releaseRepo, String jarName, InputStream jarStream) throws Exception { logger.debug("release to {}", releaseRepo.getName()); try { PutOptions putOptions = new RepositoryPlugin.PutOptions(); // TODO find sub bnd that is associated with this thing putOptions.context = this; PutResult r = releaseRepo.put(jarStream, putOptions); logger.debug("Released {} to {} in repository {}", jarName, r.artifact, releaseRepo); return r.artifact; } catch (Exception e) { msgs.Release_Into_Exception_(jarName, releaseRepo, e); return null; } }
continue; List<String> bsns = plugin.list(bsnPattern); if (bsns != null) for (String bsn : bsns) { SortedSet<Version> versions = plugin.versions(bsn); if (versions != null && !versions.isEmpty()) { Pair<Version, RepositoryPlugin> currentProvider = providerMap.get(bsn); File bundle = repo.get(bsn, version, attrs, downloadBlocker); if (bundle != null && !bundle.getName() .endsWith(".lib")) {
@Description("List all artifacts from the current repositories with their versions") public void _list(listOptions opts) throws Exception { bnd.trace("list"); Set<String> bsns = new HashSet<String>(); Instruction from = opts.from(); if (from == null) from = new Instruction("*"); for (RepositoryPlugin repo : repos) { if (from.matches(repo.getName())) bsns.addAll(repo.list(opts.query())); } bnd.trace("list " + bsns); for (String bsn : new SortedList<String>(bsns)) { if (!opts.noversions()) { Set<Version> versions = new TreeSet<Version>(); for (RepositoryPlugin repo : repos) { bnd.trace("get " + bsn + " from " + repo); if (from.matches(repo.getName())) { SortedSet<Version> result = repo.versions(bsn); if (result != null) versions.addAll(result); } } bnd.out.printf("%-40s %s%n", bsn, versions); } else { bnd.out.printf("%s%n", bsn); } } }
void repoList(List<RepositoryPlugin> repos, String mask) throws Exception { trace("list repo " + repos + " " + mask); Set<String> bsns = new TreeSet<String>(); for (RepositoryPlugin repo : repos) { bsns.addAll(repo.list(mask)); } for (String bsn : bsns) { Set<Version> versions = new TreeSet<Version>(); for (RepositoryPlugin repo : repos) { List<Version> result = repo.versions(bsn); if (result != null) versions.addAll(result); } out.printf("%-40s %s\n", bsn, versions); } }
for (Iterator<RepositoryPlugin> rp = repos.iterator(); rp.hasNext();) { RepositoryPlugin rpp = rp.next(); if (rpp.canWrite()) { writable = rpp; break; getInfo(verifier); if ( isOk()) { File put = writable.put(jar); trace("stored in %s", put); File f = repo.get(bsn, version, Strategy.LOWEST, null); if (f != null) { if (i < args.length) {
bnd.out.println("Writable repo is " + writable.getName() + " (" + writable.getLocation() + ")"); return; PutResult r = writable.put(new BufferedInputStream(new FileInputStream(file)), new RepositoryPlugin.PutOptions()); bnd.trace("put %s in %s (%s) into %s", source, writable.getName(), writable.getLocation(), r.artifact);
private void repoPut(RepositoryPlugin writable, Project project, String file, String bsn, String version) throws Exception { File f = getFile(file); if (f.isFile()) { Jar jar = project.getValidJar(f); Manifest manifest = jar.getManifest(); if (bsn != null) manifest.getMainAttributes().putValue( Constants.BUNDLE_SYMBOLICNAME, bsn); if (version != null) manifest.getMainAttributes().putValue(Constants.BUNDLE_VERSION, version); writable.put(jar); } else error("There is no such file: " + f.getAbsolutePath()); }
File[] results = plugin.get(bsn, range); if (results != null && results.length > 0) { File f = results[strategy == STRATEGY_LOWEST ? 0
@Description("Displays a list of versions for a given bsn that can be found in the current repositories.") public void _versions(VersionsOptions opts) throws Exception { TreeSet<Version> versions = new TreeSet<Version>(); String bsn = opts._().remove(0); for (RepositoryPlugin repo : repos) { versions.addAll(repo.versions(bsn)); } bnd.out.println(versions); }
for (Iterator<RepositoryPlugin> rp = repos.iterator(); rp.hasNext();) { RepositoryPlugin rpp = rp.next(); if (rpp.canWrite()) { writable = rpp; break;
RepositoryPlugin getReleaseRepo(String releaserepo) { String name = releaserepo == null ? name = getProperty(RELEASEREPO) : releaserepo; List<RepositoryPlugin> plugins = getPlugins(RepositoryPlugin.class); for (RepositoryPlugin plugin : plugins) { if (!plugin.canWrite()) continue; if (name == null) return plugin; if (name.equals(plugin.getName())) return plugin; } return null; }