Search in sources :

Example 16 with VersionRange

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());
}
Also used : FilterBuilder(aQute.bnd.osgi.resource.FilterBuilder) VersionRange(aQute.bnd.version.VersionRange)

Example 17 with VersionRange

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;
}
Also used : Processor(aQute.bnd.osgi.Processor) VersionRange(aQute.bnd.version.VersionRange) File(java.io.File)

Example 18 with VersionRange

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();
}
Also used : Version(aQute.bnd.version.Version) MavenVersion(aQute.bnd.version.MavenVersion) Matcher(java.util.regex.Matcher) VersionRange(aQute.bnd.version.VersionRange)

Example 19 with VersionRange

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;
}
Also used : Formatter(java.util.Formatter) VersionRange(aQute.bnd.version.VersionRange)

Example 20 with VersionRange

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));
}
Also used : Version(org.osgi.framework.Version) VersionRange(aQute.bnd.version.VersionRange)

Aggregations

VersionRange (aQute.bnd.version.VersionRange)31 Version (aQute.bnd.version.Version)11 File (java.io.File)6 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)5 Attrs (aQute.bnd.header.Attrs)4 Parameters (aQute.bnd.header.Parameters)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 Matcher (java.util.regex.Matcher)3 Resource (org.osgi.resource.Resource)3 Project (aQute.bnd.build.Project)2 VersionedClause (aQute.bnd.build.model.clauses.VersionedClause)2 ResourceDescriptor (aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)2 SortedList (aQute.lib.collections.SortedList)2 AndFilter (aQute.libg.filters.AndFilter)2 Filter (aQute.libg.filters.Filter)2 NotFilter (aQute.libg.filters.NotFilter)2 SimpleFilter (aQute.libg.filters.SimpleFilter)2 TreeMap (java.util.TreeMap)2