use of aQute.maven.api.Revision 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.Revision 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.Revision in project bnd by bndtools.
the class Traverser method getResources.
Promise<Map<Archive, Resource>> getResources() throws Exception {
/*
* We don't want to resolve until all the work is queued so we
* initialize the count to 1 and call finish after queuing all the work.
*/
if (count.compareAndSet(-1, 1)) {
try {
if (!uris.isEmpty()) {
for (URI uri : uris) {
File in = client.build().useCache().age(1, TimeUnit.DAYS).go(uri);
POM pom = new POM(repo, in);
parsePom(pom, ROOT);
}
} else {
for (Revision revision : revisions) parse(revision.archive("jar", null), ROOT);
}
} finally {
finish();
}
}
return deferred.getPromise();
}
use of aQute.maven.api.Revision in project bnd by bndtools.
the class PomRepositoryTest method testRepository.
public void testRepository() throws Exception {
MavenRepository repo = getRepo();
Revision revision = Revision.valueOf("bcel:bcel:5.1");
PomRepository pom = new PomRepository(repo, client, location).revisions(Collections.singleton(revision));
assertTrue(location.isFile());
try (XMLResourceParser xp = new XMLResourceParser(location)) {
List<Resource> parse = xp.parse();
assertEquals(parse.size(), pom.getResources().size());
}
}
use of aQute.maven.api.Revision in project bnd by bndtools.
the class RepoActions method addUpdate.
void addUpdate(final BundleDescriptor bd, Map<String, Runnable> map) throws Exception {
try {
Revision rev = bd.archive.revision;
Program prog = rev.program;
List<Revision> revisions = repo.storage.getRevisions(prog);
if (revisions.size() > 1) {
final Revision last = revisions.get(revisions.size() - 1);
if (!rev.equals(last)) {
map.put("Update to " + last, new Runnable() {
@Override
public void run() {
try {
repo.index.remove(bd.archive);
repo.index.add(last.archive(bd.archive.extension, bd.archive.classifier));
addDependency(bd.archive, MavenScope.runtime);
} catch (Exception e) {
throw Exceptions.duck(e);
}
}
});
} else
map.put("-Update", null);
}
} catch (Exception e) {
map.put("-Update [" + e + "]", null);
}
}
Aggregations