use of aQute.bnd.version.Version in project bnd by bndtools.
the class MavenVersionTest method testQualifierWithoutSeparator.
public void testQualifierWithoutSeparator() {
MavenVersion mv = MavenVersion.parseString("1.2.3rc1");
assertEquals(new Version(1, 2, 3, "rc1"), mv.getOSGiVersion());
assertFalse(mv.isSnapshot());
mv = MavenVersion.parseString("1.2rc1");
assertEquals(new Version(1, 2, 0, "rc1"), mv.getOSGiVersion());
assertFalse(mv.isSnapshot());
mv = MavenVersion.parseString("1rc1");
assertEquals(new Version(1, 0, 0, "rc1"), mv.getOSGiVersion());
assertFalse(mv.isSnapshot());
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class MavenVersionTest method testQualifierWithDashSeparator.
public void testQualifierWithDashSeparator() {
MavenVersion mv = MavenVersion.parseString("1.2.3-beta-1");
assertEquals(new Version(1, 2, 3, "beta-1"), mv.getOSGiVersion());
assertFalse(mv.isSnapshot());
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class FileRepoTest method testIndex.
/**
* Test a repo with an index
*/
public void testIndex() throws Exception {
//
// Check if the index property works
// by verifying the diff between the
// testRepo and the indexed Repo
//
assertNull(testRepo.getResources());
assertNotNull(indexedRepo.getResources());
//
// Check that we can actually put a resource
//
PutResult put = indexedRepo.put(IO.getFile("jar/osgi.jar").toURI().toURL().openStream(), null);
assertNotNull(put);
// Can we get it?
ResourceDescriptor desc = indexedRepo.getDescriptor("osgi", new Version("4.0"));
assertNotNull(desc);
// Got the same file?
assertTrue(Arrays.equals(put.digest, desc.id));
//
// Check if the description was copied
//
assertEquals("OSGi Service Platform Release 4 Interfaces and Classes for use in compiling bundles.", desc.description);
//
// We must be able to access by its sha1
//
ResourceDescriptor resource = indexedRepo.getResource(put.digest);
assertTrue(Arrays.equals(resource.id, desc.id));
//
// Check if we now have a set of resources
//
SortedSet<ResourceDescriptor> resources = indexedRepo.getResources();
assertEquals(1, resources.size());
ResourceDescriptor rd = resources.iterator().next();
assertTrue(Arrays.equals(rd.id, put.digest));
//
// Check if the bsn brings us back
//
File file = indexedRepo.get(desc.bsn, desc.version, null);
assertNotNull(file);
assertTrue(Arrays.equals(put.digest, SHA1.digest(file).digest()));
byte[] digest = SHA256.digest(file).digest();
assertTrue(Arrays.equals(rd.sha256, digest));
//
// Delete and see if it is really gone
//
indexedRepo.delete(desc.bsn, desc.version);
resources = indexedRepo.getResources();
assertEquals(0, resources.size());
file = indexedRepo.get(desc.bsn, desc.version, null);
assertNull(file);
resource = indexedRepo.getResource(put.digest);
assertNull(resource);
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class Macro method _range.
public String _range(String[] args) {
verifyCommand(args, _rangeHelp, _rangePattern, 2, 3);
Version version = null;
if (args.length >= 3) {
String string = args[2];
if (isLocalTarget(string))
return LITERALVALUE;
version = new Version(string);
} else {
String v = domain.getProperty("@");
if (v == null)
return LITERALVALUE;
version = new Version(v);
}
String spec = args[1];
Matcher m = RANGE_MASK.matcher(spec);
m.matches();
String floor = m.group(1);
String floorMask = m.group(2);
String ceilingMask = m.group(3);
String ceiling = m.group(4);
String left = version(version, floorMask);
String right = version(version, ceilingMask);
StringBuilder sb = new StringBuilder();
sb.append(floor);
sb.append(left);
sb.append(",");
sb.append(right);
sb.append(ceiling);
String s = sb.toString();
VersionRange vr = new VersionRange(s);
if (!(vr.includes(vr.getHigh()) || vr.includes(vr.getLow()))) {
domain.error("${range} macro created an invalid range %s from %s and mask %s", s, version, spec);
}
return sb.toString();
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class OSInformation method getOperatingSystemAliases.
public static OSNameVersion getOperatingSystemAliases(String sysPropOsName, String sysPropOsVersion) {
OSNameVersion nc = new OSNameVersion();
if (sysPropOsName.startsWith("Windows")) {
if (sysPropOsVersion.startsWith("10.0")) {
nc.osversion = new Version(10, 0, 0);
nc.osnames = "Windows10,Windows 10,Win32";
} else if (sysPropOsVersion.startsWith("6.3")) {
nc.osversion = new Version(6, 3, 0);
nc.osnames = "Windows8.1,Windows 8.1,Win32";
} else if (sysPropOsVersion.startsWith("6.2")) {
nc.osversion = new Version(6, 2, 0);
nc.osnames = "Windows8,Windows 8,Win32";
} else if (sysPropOsVersion.startsWith("6.1")) {
nc.osversion = new Version(6, 1, 0);
nc.osnames = "Windows7,Windows 7,Win32";
} else if (sysPropOsVersion.startsWith("6.0")) {
nc.osversion = new Version(6, 0, 0);
nc.osnames = "WindowsVista,WinVista,Windows Vista,Win32";
} else if (sysPropOsVersion.startsWith("5.1")) {
nc.osversion = new Version(5, 1, 0);
nc.osnames = "WindowsXP,WinXP,Windows XP,Win32";
} else {
nc = null;
}
} else if (sysPropOsName.startsWith("Mac OS X")) {
nc.osversion = convertUnixKernelVersion(sysPropOsVersion);
nc.osnames = "MacOSX,Mac OS X";
return nc;
} else if (sysPropOsName.toLowerCase().startsWith("linux")) {
nc.osversion = convertUnixKernelVersion(sysPropOsVersion);
nc.osnames = "Linux";
} else if (sysPropOsName.startsWith("Solaris")) {
nc.osversion = convertUnixKernelVersion(sysPropOsVersion);
nc.osnames = "Solaris";
} else if (sysPropOsName.startsWith("AIX")) {
nc.osversion = convertUnixKernelVersion(sysPropOsVersion);
nc.osnames = "AIX";
} else if (sysPropOsName.startsWith("HP-UX")) {
nc.osversion = convertUnixKernelVersion(sysPropOsVersion);
nc.osnames = "HPUX,hp-ux";
}
return nc;
}
Aggregations