use of aQute.service.library.Coordinate in project bnd by bndtools.
the class JustAnotherPackageManager method getCandidateAsync.
public ArtifactData getCandidateAsync(String arg) throws Exception {
logger.debug("coordinate {}", arg);
if (isUrl(arg))
try {
ArtifactData data = putAsync(new URI(arg));
data.local = true;
return data;
} catch (Exception e) {
logger.debug("hmm, not a valid url {}, will try the server", arg);
return null;
}
File f = IO.getFile(arg);
if (f.isFile())
try {
ArtifactData data = putAsync(f.toURI());
data.local = true;
return data;
} catch (Exception e) {
logger.debug("hmm, not a valid file {}, will try the server", arg);
return null;
}
Coordinate c = new Coordinate(arg);
if (c.isSha()) {
ArtifactData r = get(c.getSha());
if (r != null)
return r;
}
Revision revision = library.getRevisionByCoordinate(c);
if (revision == null)
return null;
logger.debug("revision {}", Hex.toHexString(revision._id));
ArtifactData ad = get(revision._id);
if (ad != null) {
logger.debug("found in cache");
return ad;
}
URI url = revision.urls.iterator().next();
ArtifactData artifactData = putAsync(url);
artifactData.coordinate = c;
return artifactData;
}
use of aQute.service.library.Coordinate in project bnd by bndtools.
the class Repository method getRevisionRef.
/**
* Find a revisionref for a bsn/version
*
* @param bsn
* @param version
* @throws Exception
*/
private RevisionRef getRevisionRef(String bsn, Version version) throws Exception {
// Handle when we have a sha reference
String id = bsn + "-" + version;
if (notfoundref.contains(id))
return null;
if (isSha(bsn) && version.equals(Version.LOWEST)) {
Revision r = getRevision(new Coordinate(bsn));
if (r == null)
return null;
return new RevisionRef(r);
}
logger.debug("Looking for {}-{}", bsn, version);
for (RevisionRef r : getRevisionRefs(bsn)) {
Version v = toVersion(r.baseline, r.qualifier);
if (v.equals(version))
return r;
}
notfoundref.add(id);
return null;
}
use of aQute.service.library.Coordinate in project bnd by bndtools.
the class Main method printRevisions.
void printRevisions(Iterable<? extends Revision> revisions, RevisionPrintOptions po) {
if (po.coordinate()) {
for (Revision r : revisions) {
out.println(new Coordinate(r));
}
return;
}
Justif j = new Justif(140, 40, 70, 82, 100, 120);
try (Formatter f = j.formatter()) {
for (Revision r : revisions) {
f.format("[%s] ", r.phase.getIdentifier());
if (r.groupId.equals(Library.OSGI_GROUP) || r.groupId.equals(Library.SHA_GROUP))
f.format("%s ", r.artifactId);
else
f.format("%s:%s ", r.groupId, r.artifactId);
f.format("\t0%s\t1%tF\t2%s", r.version, new Date(r.modified), Hex.toHexString(r._id));
if (po.description() && r.description != null) {
f.format("\n \t1%s", r.description);
}
f.format("\n");
}
out.println(j.wrap());
}
}
use of aQute.service.library.Coordinate 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.Coordinate 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