use of aQute.bnd.version.Version in project bnd by bndtools.
the class Macro method version.
String version(Version version, String mask) {
if (version == null) {
String v = domain.getProperty("@");
if (v == null) {
return LITERALVALUE;
}
version = new Version(v);
}
StringBuilder sb = new StringBuilder();
String del = "";
for (int i = 0; i < mask.length(); i++) {
char c = mask.charAt(i);
String result = null;
if (c != '~') {
if (i == 3) {
result = version.getQualifier();
MavenVersion mv = new MavenVersion(version);
if (c == 'S') {
// we have a request for a Maven snapshot
if (mv.isSnapshot())
return sb.append("-SNAPSHOT").toString();
} else if (c == 's') {
// we have a request for a Maven snapshot
if (mv.isSnapshot())
return sb.append("-SNAPSHOT").toString();
else
return sb.toString();
}
} else if (Character.isDigit(c)) {
// Handle masks like +00, =+0
result = String.valueOf(c);
} else {
int x = version.get(i);
switch(c) {
case '+':
x++;
break;
case '-':
x--;
break;
case '=':
break;
}
result = Integer.toString(x);
}
if (result != null) {
sb.append(del);
del = ".";
sb.append(result);
}
}
}
return sb.toString();
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class Jar method getTimelessDigest.
public byte[] getTimelessDigest() throws Exception {
check();
MessageDigest md = MessageDigest.getInstance("SHA1");
OutputStream dout = new DigestOutputStream(IO.nullStream, md);
// dout = System.out;
Manifest m = getManifest();
if (m != null) {
Manifest m2 = new Manifest(m);
Attributes main = m2.getMainAttributes();
String lastmodified = (String) main.remove(new Attributes.Name(Constants.BND_LASTMODIFIED));
String version = main.getValue(new Attributes.Name(Constants.BUNDLE_VERSION));
if (version != null && Verifier.isVersion(version)) {
Version v = new Version(version);
main.putValue(Constants.BUNDLE_VERSION, v.getWithoutQualifier().toString());
}
writeManifest(m2, dout);
for (Map.Entry<String, Resource> entry : getResources().entrySet()) {
String path = entry.getKey();
if (path.equals(manifestName))
continue;
Resource resource = entry.getValue();
dout.write(path.getBytes(UTF_8));
resource.write(dout);
}
}
return md.digest();
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class Macro method _version.
public String _version(String[] args) {
verifyCommand(args, _versionHelp, null, 2, 3);
String mask = args[1];
Version version = null;
if (args.length >= 3) {
if (isLocalTarget(args[2]))
return LITERALVALUE;
version = Version.parseVersion(args[2]);
}
return version(version, mask);
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class AgainstNexusTest method testBasic.
public void testBasic() throws Exception {
if (skip)
return;
config(null);
assertEquals("[group:artifact]", repo.list(null).toString());
assertEquals("[1.0.0.SNAPSHOT]", repo.versions("group:artifact").toString());
File f = repo.get("group:artifact", new Version("1.0.0.SNAPSHOT"), null);
assertEquals(1497, f.length());
System.out.println(f);
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class TestWrapper method augmentTest.
private void augmentTest(InfoRepository repo) throws Exception, IOException {
assertNotNull(repo.get("biz.aQute.jpm.daemon", new Version("1.1.0"), null));
InfoRepositoryWrapper iw = new InfoRepositoryWrapper(tmp, Collections.singleton(repo));
Properties augments = new UTF8Properties();
augments.load(new StringReader("biz.aQute.jpm.daemon: cap=test;test=1\n"));
iw.addAugment(augments);
//
// Get the test and identity capability
//
Requirement testreq = new CapReqBuilder("test").filter("(test=1)").buildSyntheticRequirement();
Requirement identity = new CapReqBuilder("osgi.identity").filter("(osgi.identity=biz.aQute.jpm.daemon)").buildSyntheticRequirement();
Map<Requirement, Collection<Capability>> result = iw.findProviders(Arrays.asList(testreq, identity));
assertNotNull(result);
assertEquals(2, result.size());
//
// Test if they come from the same resource
//
Capability testcap = result.get(testreq).iterator().next();
Capability identitycap = result.get(identity).iterator().next();
assertNotNull(testcap);
assertNotNull(identitycap);
assertEquals(testcap.getResource(), identitycap.getResource());
iw.close();
}
Aggregations