use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.
the class Repository method getResources.
/**
* Answer the resource descriptors from a URL
*/
// @Override
public Set<ResourceDescriptor> getResources(URI url, boolean includeDependencies) throws Exception {
Matcher m = JPM_REVISION_URL_PATTERN.matcher(url.toString());
if (!m.matches()) {
return null;
}
Set<ResourceDescriptor> resources = new HashSet<ResourceDescriptor>();
Revision revision = getRevision(new Coordinate(m.group(1), m.group(2), m.group(3), m.group(4)));
if (revision != null) {
ResourceDescriptor rd = createResourceDescriptor(new RevisionRef(revision));
resources.add(rd);
if (includeDependencies) {
for (RevisionRef dependency : getLibrary().getClosure(revision._id, false)) {
ResourceDescriptor dep = createResourceDescriptor(dependency);
dep.dependency = true;
resources.add(dep);
}
}
}
return resources;
}
use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.
the class Repository method getRevisionRefs.
private List<RevisionRef> getRevisionRefs(String bsn) throws Exception {
String classifier = null;
String[] parts = bsn.split("__");
if (parts.length == 3) {
bsn = parts[0] + "__" + parts[1];
classifier = parts[2];
}
Program program = getProgram(bsn, false);
if (program != null) {
List<RevisionRef> refs = new ArrayList<Library.RevisionRef>();
for (RevisionRef r : program.revisions) {
if (eq(classifier, r.classifier))
refs.add(r);
}
return refs;
}
return Collections.emptyList();
}
use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.
the class Repository method revisionTooltip.
private String revisionTooltip(String bsn, Version version) throws Exception {
RevisionRef r = getRevisionRef(bsn, version);
if (r == null)
return null;
try (Formatter sb = new Formatter()) {
sb.format("[%s:%s", r.groupId, r.artifactId);
if (r.classifier != null) {
sb.format(":%s", r.classifier);
}
sb.format("@%s] %s\n\n", r.version, r.phase);
if (r.releaseSummary != null)
sb.format("%s\n\n", r.releaseSummary);
if (r.description != null)
sb.format("%s\n\n", r.description.replaceAll("#\\s*", ""));
sb.format("Size: %s\n", size(r.size, 0));
sb.format("SHA-1: %s\n", Hex.toHexString(r.revision));
sb.format("Age: %s\n", age(r.created));
sb.format("URL: %s\n", r.urls);
File f = getCache().getPath(bsn, version.toString(), r.revision);
if (f.isFile() && f.length() == r.size)
sb.format("Cached %s\n", f);
else
sb.format("Not downloaded\n");
if (bsn.indexOf("__") >= 0) {
sb.format("\nThis artifact has no OSGi metadata. Its coordinates are %s:%s@%s\n", r.groupId, r.artifactId, r.version);
}
Program p = getProgram(bsn, false);
if (p != null) {
Runnable update = getUpdateAction(p, r);
if (update != null) {
sb.format("%c This version can be updated to %s\n", DOWN_ARROW, update);
}
}
File sources = getCache().getPath(bsn, version.toString(), r.revision, true);
if (sources.isFile())
sb.format("Has sources: %s\n", sources.getAbsolutePath());
else
sb.format("No sources\n");
j.wrap((StringBuilder) sb.out());
return sb.toString().trim();
}
}
use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.
the class Repository method query.
// @Override
public Set<ResourceDescriptor> query(String query) throws Exception {
Set<ResourceDescriptor> resources = new HashSet<ResourceDescriptor>();
RevisionRef master = null;
RevisionRef staging = null;
for (Program p : getLibrary().getQueryPrograms(query, 0, 100)) {
for (RevisionRef ref : p.revisions) {
if (master == null && ref.phase == Library.Phase.MASTER) {
master = ref;
} else if (staging != null && ref.phase == Library.Phase.STAGING) {
staging = ref;
}
}
if (master != null)
resources.add(createResourceDescriptor(master));
if (staging != null)
resources.add(createResourceDescriptor(staging));
}
return resources;
}
use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.
the class Repository method cleanUp.
/**
* Remove any unused entries in this repository
*
* @throws Exception
*/
void cleanUp() throws Exception {
Workspace workspace = registry.getPlugin(Workspace.class);
Set<Container> set = new HashSet<Container>();
for (Project project : workspace.getAllProjects()) {
set.addAll(project.getBuildpath());
set.addAll(project.getRunbundles());
set.addAll(project.getRunpath());
set.addAll(project.getTestpath());
set.addAll(project.getBootclasspath());
set.addAll(project.getClasspath());
//
// This should be replaced with project.getRunfw()
//
String s = project.getProperty(Constants.RUNFW);
List<Container> bundles = project.getBundles(Strategy.HIGHEST, s, Constants.RUNFW);
set.addAll(bundles);
File base = project.getBase();
for (File sub : base.listFiles()) {
if (sub.getName().endsWith(".bndrun")) {
try (Project bndrun = new Project(workspace, base, sub)) {
set.addAll(bndrun.getRunbundles());
set.addAll(bndrun.getRunpath());
set.addAll(bndrun.getTestpath());
set.addAll(bndrun.getBootclasspath());
set.addAll(bndrun.getClasspath());
}
}
}
}
Set<RevisionRef> refs = new HashSet<RevisionRef>(index.getRevisionRefs());
Set<RevisionRef> keep = new HashSet<RevisionRef>();
for (Container libOrRev : set) {
for (Container c : libOrRev.getMembers()) {
logger.debug("Dependency {}", c);
if (!Verifier.isVersion(c.getVersion()))
continue;
RevisionRef ref = index.getRevisionRef(c.getBundleSymbolicName(), new Version(c.getVersion()));
if (ref != null)
refs.remove(ref);
else {
// missing!
logger.debug("Missing {}", c.getBundleSymbolicName());
Coordinate coord = new Coordinate(c.getBundleSymbolicName());
Revision rev = getLibrary().getRevisionByCoordinate(coord);
if (rev != null) {
index.addRevision(new RevisionRef(rev));
} else
System.out.printf("not found %s\n", c);
}
keep.add(ref);
}
}
for (RevisionRef ref : refs) {
index.delete(ref.bsn, Index.toVersion(ref));
}
index.save();
}
Aggregations