use of aQute.bnd.service.RepositoryPlugin.PutOptions in project bnd by bndtools.
the class Project method install.
private void install(File f, RepositoryPlugin repo, Attrs value) throws Exception {
try (Processor p = new Processor()) {
p.getProperties().putAll(value);
PutOptions options = new PutOptions();
options.context = p;
try (InputStream in = IO.stream(f)) {
repo.put(in, options);
} catch (Exception e) {
exception(e, "Cannot install %s into %s because %s", f, repo.getName(), e);
}
}
}
use of aQute.bnd.service.RepositoryPlugin.PutOptions in project bnd by bndtools.
the class FileRepoTest method testBundleNotModifiedOnPut.
public void testBundleNotModifiedOnPut() throws Exception {
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
File dstBundle = null;
try {
File srcBundle = IO.getFile("testresources/test.jar");
byte[] srcSha = calculateHash(sha1, srcBundle);
PutOptions options = new RepositoryPlugin.PutOptions();
options.digest = srcSha;
PutResult r = testRepo.put(new BufferedInputStream(new FileInputStream(srcBundle)), options);
dstBundle = new File(r.artifact);
assertEquals(hashToString(srcSha), hashToString(r.digest));
assertTrue(MessageDigest.isEqual(srcSha, r.digest));
} finally {
if (dstBundle != null) {
delete(dstBundle.getParentFile());
}
}
}
use of aQute.bnd.service.RepositoryPlugin.PutOptions in project bnd by bndtools.
the class Project method releaseRepo.
private URI releaseRepo(RepositoryPlugin releaseRepo, String jarName, InputStream jarStream) throws Exception {
logger.debug("release to {}", releaseRepo.getName());
try {
PutOptions putOptions = new RepositoryPlugin.PutOptions();
// TODO find sub bnd that is associated with this thing
putOptions.context = this;
PutResult r = releaseRepo.put(jarStream, putOptions);
logger.debug("Released {} to {} in repository {}", jarName, r.artifact, releaseRepo);
return r.artifact;
} catch (Exception e) {
msgs.Release_Into_Exception_(jarName, releaseRepo, e);
return null;
}
}
use of aQute.bnd.service.RepositoryPlugin.PutOptions in project bnd by bndtools.
the class Project method copy.
public void copy(RepositoryPlugin source, Instructions filter, RepositoryPlugin destination) throws Exception {
assert source != null;
assert destination != null;
logger.info("copy from repo {} to {} with filter {}", source, destination, filter);
for (String bsn : source.list(null)) {
for (Version version : source.versions(bsn)) {
if (filter == null || filter.matches(bsn)) {
logger.info("copy {}:{}", bsn, version);
File file = source.get(bsn, version, null);
if (file.getName().endsWith(".jar")) {
try (InputStream in = IO.stream(file)) {
PutOptions po = new PutOptions();
po.bsn = bsn;
po.context = null;
po.type = "bundle";
po.version = version;
PutResult put = destination.put(in, po);
} catch (Exception e) {
logger.error("Failed to copy {}-{}", e, bsn, version);
error("Failed to copy %s:%s from %s to %s, error: %s", bsn, version, source, destination, e);
}
}
}
}
}
}
use of aQute.bnd.service.RepositoryPlugin.PutOptions in project bnd by bndtools.
the class MavenBndRepoTest method testPutRemoteSnapshot.
public void testPutRemoteSnapshot() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("releaseUrl", null);
map.put("snapshotUrl", fnx.getBaseURI() + "/repo/");
config(map);
File jar = IO.getFile("testresources/snapshot.jar");
try (Processor context = new Processor()) {
context.setProperty("-maven-release", "remote;snapshot=1");
PutOptions put = new PutOptions();
put.context = context;
PutResult r = repo.put(new FileInputStream(jar), put);
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT.jar");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT.pom");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT-sources.jar");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1.pom");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1-sources.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
File f = IO.getFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
String s = IO.collect(f);
assertTrue(s.contains("3.2.0-19700101.000000"));
}
try (Processor context = new Processor()) {
context.setProperty("-maven-release", "remote;snapshot=10000");
PutOptions put = new PutOptions();
put.context = context;
PutResult r = repo.put(new FileInputStream(jar), put);
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT.jar");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT.pom");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT-sources.jar");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1.pom");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1-sources.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000010-2.pom");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000010-2.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000010-2-sources.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000010-2-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
File f = IO.getFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
String s = IO.collect(f);
assertTrue(s.contains("<value>3.2.0-19700101.000000-1</value>"));
assertTrue(s.contains("<value>3.2.0-19700101.000010-2</value>"));
}
}
Aggregations