use of aQute.bnd.version.VersionRange in project bnd by bndtools.
the class FilterBuilderTest method testVersionRange.
public void testVersionRange() {
assertEquals("(&(version>=1.0.0)(!(version>=2.0.0)))", fb.in("version", new VersionRange("[1,2)")).toString());
fb = new FilterBuilder();
assertEquals("(&(!(version<=1.0.0))(version<=2.0.0))", fb.in("version", new VersionRange("(1,2]")).toString());
}
use of aQute.bnd.version.VersionRange in project bnd by bndtools.
the class MavenRepository method get.
private File[] get(String bsn, String version) throws Exception {
VersionRange range = new VersionRange("0");
if (version != null)
range = new VersionRange(version);
List<BsnToMavenPath> plugins = ((Processor) reporter).getPlugins(BsnToMavenPath.class);
if (plugins.isEmpty())
plugins.add(this);
for (BsnToMavenPath cvr : plugins) {
String[] paths = cvr.getGroupAndArtifact(bsn);
if (paths != null) {
File[] files = find(paths[0], paths[1], range);
if (files != null)
return files;
}
}
logger.debug("Cannot find in maven: {}-{}", bsn, version);
return null;
}
use of aQute.bnd.version.VersionRange 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.VersionRange in project bnd by bndtools.
the class OBRFragment method filter.
// TODO finish
private static String filter(String ns, String primary, Map<String, String> value) {
try (Formatter f = new Formatter()) {
f.format("(&(%s=%s)", ns, primary);
for (String key : value.keySet()) {
if (key.equals("version") || key.equals("bundle-version")) {
VersionRange vr = new VersionRange(value.get(key));
} else {
f.format("(%s=%s)", key, value.get(key));
}
}
f.format(")");
}
return null;
}
use of aQute.bnd.version.VersionRange in project bndtools by bndtools.
the class ResolutionWizard method createVersionRange.
private static VersionRange createVersionRange(Version version) {
Version base = new Version(version.getMajor(), version.getMinor(), version.getMicro());
Version next = new Version(version.getMajor(), version.getMinor(), version.getMicro() + 1);
return new VersionRange(String.format("[%s,%s)", base, next));
}
Aggregations