use of aQute.maven.api.Archive in project bnd by bndtools.
the class ReleasePluginImpl method end.
/*
* End the release cyle. This will index all artifacts released to the
* repository since the begin.
*/
void end(Project p, IMavenRepo storage) throws Exception {
if (releasedArtifacts.isEmpty())
return;
if (p != indexProject)
throw new IllegalArgumentException("Different project that started the release plugin then that ended it " + indexProject + ":" + p);
if (master == null)
throw new IllegalArgumentException("The index project was never released so GAV is unknown for index");
Archive index = master.getRevision().archive("xml", "index");
String prefix = makeDots(index.remotePath);
ResourcesRepository repository = createIndex(releasedArtifacts, storage, prefix);
saveToXml(p, storage, index, repository);
}
use of aQute.maven.api.Archive in project bnd by bndtools.
the class RepoActions method addSources.
void addSources(final BundleDescriptor bd, Map<String, Runnable> map) throws Exception {
Promise<File> pBinary = repo.storage.get(bd.archive);
if (pBinary.getFailure() == null) {
final File binary = pBinary.getValue();
final File out = new File(binary.getParentFile(), "+" + binary.getName());
if (!out.isFile()) {
Archive a = bd.archive.revision.archive("jar", "sources");
Promise<File> pSources = repo.storage.get(a);
if (pSources.getFailure() == null) {
final File sources = pSources.getValue();
if (sources.isFile() && sources.length() > 1000) {
map.put("Add Sources", new Runnable() {
@Override
public void run() {
try {
try (Jar src = new Jar(sources)) {
try (Jar bin = new Jar(binary)) {
bin.setDoNotTouchManifest();
for (String path : src.getResources().keySet()) bin.putResource("OSGI-OPT/src/" + path, src.getResource(path));
bin.write(out);
}
out.setLastModified(System.currentTimeMillis());
}
} catch (Exception e) {
throw Exceptions.duck(e);
}
}
});
return;
}
}
}
}
map.put("-Add Sources", null);
}
use of aQute.maven.api.Archive in project bnd by bndtools.
the class MavenBndRepository method addPom.
private boolean addPom(URI uri) throws Exception {
try {
// http://search.maven.org/remotecontent?filepath=com/netflix/governator/governator-commons-cli/1.12.10/governator-commons-cli-1.12.10.pom
IPom pom = storage.getPom(client.connect(uri.toURL()));
Archive binaryArchive = pom.binaryArchive();
index.add(binaryArchive);
return true;
} catch (FileNotFoundException e) {
return false;
} catch (Exception e) {
logger.debug("Failure to parse {}", uri, e);
return false;
}
}
use of aQute.maven.api.Archive in project bnd by bndtools.
the class MavenBndRepository method get.
@Override
public File get(String bsn, Version version, Map<String, String> properties, final DownloadListener... listeners) throws Exception {
init();
BundleDescriptor descriptor = index.getDescriptor(bsn, version);
if (descriptor == null)
return null;
Archive archive = descriptor.archive;
if (archive != null) {
final File file = storage.toLocalFile(archive);
final File withSources = new File(file.getParentFile(), "+" + file.getName());
if (withSources.isFile() && withSources.lastModified() > file.lastModified()) {
if (listeners.length == 0)
return withSources;
for (DownloadListener dl : listeners) dl.success(withSources);
return withSources;
}
Promise<File> promise = index.updateAsync(descriptor, storage.get(archive));
if (listeners.length == 0)
return promise.getValue();
promise.then(new Success<File, Void>() {
@Override
public Promise<Void> call(Promise<File> resolved) throws Exception {
File value = resolved.getValue();
if (value == null) {
throw new FileNotFoundException("Download failed");
}
for (DownloadListener dl : listeners) {
try {
dl.success(value);
} catch (Exception e) {
reporter.exception(e, "Download listener failed in success callback %s", dl);
}
}
return null;
}
}).then(null, new Failure() {
@Override
public void fail(Promise<?> resolved) throws Exception {
String reason = Exceptions.toString(resolved.getFailure());
for (DownloadListener dl : listeners) {
try {
dl.failure(file, reason);
} catch (Exception e) {
reporter.exception(e, "Download listener failed in failure callback %s", dl);
}
}
}
});
return file;
}
return null;
}
use of aQute.maven.api.Archive in project bnd by bndtools.
the class Traverser method parsePom.
private void parsePom(POM pom, String parent) throws Exception {
Map<Program, Dependency> dependencies = pom.getDependencies(EnumSet.of(MavenScope.compile, MavenScope.runtime), false);
for (Dependency d : dependencies.values()) {
d.bindToVersion(repo);
Archive archive = d.getArchive();
if (archive == null) {
logger.debug("pom {} has bad dependency {}", pom.getRevision(), d);
} else
parse(archive, parent);
}
}
Aggregations