use of aQute.maven.api.Archive in project bnd by bndtools.
the class MavenRepoTest method testBasic.
public void testBasic() throws Exception {
Program program = Program.valueOf("commons-cli", "commons-cli");
List<Revision> revisions = storage.getRevisions(program);
assertNotNull(revisions);
assertEquals(3, revisions.size());
Revision revision = program.version(new MavenVersion("1.4-SNAPSHOT"));
assertTrue(revisions.contains(revision));
List<Archive> snapshotArchives = storage.getSnapshotArchives(revision);
assertNotNull(snapshotArchives);
assertEquals(10, snapshotArchives.size());
Archive archive = storage.getResolvedArchive(revision, "pom", null);
assertNotNull(archive);
assertEquals("1.4-20160119.062305-9", archive.snapshot.toString());
File file = storage.get(archive).getValue();
assertNotNull(file);
assertEquals(10373L, file.length());
}
use of aQute.maven.api.Archive in project bnd by bndtools.
the class MavenRepoTest method testSnapshotCaches.
public void testSnapshotCaches() throws Exception {
File fpom = IO.getFile(local, "commons-cli/commons-cli/1.4-SNAPSHOT/commons-cli-1.4-SNAPSHOT.pom");
Program program = Program.valueOf("commons-cli", "commons-cli");
Revision revision = Program.valueOf("commons-cli", "commons-cli").version("1.4-SNAPSHOT");
Archive apom = revision.archive("pom", null);
assertFalse(fpom.exists());
assertFalse(apom.isResolved());
File f = storage.get(apom).getValue();
assertEquals(fpom.getAbsolutePath(), f.getAbsolutePath());
assertRecent(f);
long flastModified = f.lastModified();
Thread.sleep(1001);
f = storage.get(apom).getValue();
assertEquals(flastModified, f.lastModified());
f.setLastModified(0);
assertFalse(Math.abs(System.currentTimeMillis() - f.lastModified()) <= 2000);
f = storage.get(apom).getValue();
assertFalse(f.lastModified() != 0);
}
use of aQute.maven.api.Archive in project bnd by bndtools.
the class BndPomRepository method get.
@Override
public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception {
init();
ResourceInfo resource = bridge.getInfo(bsn, version);
if (resource == null)
return null;
String name = resource.getInfo().name();
Archive archive = Archive.valueOf(name);
Promise<File> p = repoImpl.getMavenRepository().get(archive);
if (listeners.length == 0)
return p.getValue();
new DownloadListenerPromise(reporter, name + ": get " + bsn + ";" + version, p, listeners);
return repoImpl.getMavenRepository().toLocalFile(archive);
}
use of aQute.maven.api.Archive in project bnd by bndtools.
the class IndexFile method sync.
private void sync() throws Exception {
List<Promise<Void>> sync = new ArrayList<>(promises.size());
for (Iterator<Entry<Archive, Promise<File>>> i = promises.entrySet().iterator(); i.hasNext(); ) {
Entry<Archive, Promise<File>> entry = i.next();
final Archive archive = entry.getKey();
Promise<File> promise = entry.getValue();
i.remove();
sync.add(promise.<Void>then(null, new Failure() {
@Override
public void fail(Promise<?> resolved) throws Exception {
reporter.exception(resolved.getFailure(), "Failed to sync %s", archive);
}
}));
}
// block until all promises resolved
Promises.all(sync).getFailure();
}
use of aQute.maven.api.Archive in project bnd by bndtools.
the class IndexFile method loadIndexFile.
private void loadIndexFile() throws Exception {
lastModified = indexFile.lastModified();
Set<Archive> toBeDeleted = new HashSet<>(descriptors.keySet());
if (indexFile.isFile()) {
lock.readLock().lock();
try (BufferedReader rdr = IO.reader(indexFile)) {
String line;
while ((line = rdr.readLine()) != null) {
line = Strings.trim(line);
if (line.startsWith("#") || line.isEmpty())
continue;
Archive a = Archive.valueOf(line);
if (a == null) {
reporter.error("MavenBndRepository: invalid entry %s in file %s", line, indexFile);
} else {
toBeDeleted.remove(a);
loadDescriptorAsync(a);
}
}
} finally {
lock.readLock().unlock();
}
this.descriptors.keySet().removeAll(toBeDeleted);
this.promises.keySet().removeAll(toBeDeleted);
}
}
Aggregations