Search in sources :

Example 61 with Version

use of aQute.bnd.version.Version in project bndtools by bndtools.

the class RunBlacklistPart method createRequirement.

private static Requirement createRequirement(Object elem) {
    String bsn = null;
    Version version = null;
    if (elem instanceof RepositoryBundle) {
        bsn = ((RepositoryBundle) elem).getBsn();
    } else if (elem instanceof RepositoryBundleVersion) {
        RepositoryBundleVersion rbv = (RepositoryBundleVersion) elem;
        bsn = rbv.getBsn();
        version = rbv.getVersion();
    } else if (elem instanceof ProjectBundle) {
        bsn = ((ProjectBundle) elem).getBsn();
    }
    if (bsn != null) {
        Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bsn);
        if (version != null) {
            filter = new AndFilter().addChild(filter).addChild(new SimpleFilter("version", Operator.GreaterThanOrEqual, version.toString()));
        }
        Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
        return req;
    }
    return null;
}
Also used : RepositoryBundle(bndtools.model.repo.RepositoryBundle) ProjectBundle(bndtools.model.repo.ProjectBundle) CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) AndFilter(aQute.libg.filters.AndFilter) Requirement(org.osgi.resource.Requirement) RepositoryBundleVersion(bndtools.model.repo.RepositoryBundleVersion) Version(aQute.bnd.version.Version) RepositoryBundleVersion(bndtools.model.repo.RepositoryBundleVersion) SimpleFilter(aQute.libg.filters.SimpleFilter) AndFilter(aQute.libg.filters.AndFilter) Filter(aQute.libg.filters.Filter) LiteralFilter(aQute.libg.filters.LiteralFilter) SimpleFilter(aQute.libg.filters.SimpleFilter)

Example 62 with Version

use of aQute.bnd.version.Version in project bnd by bndtools.

the class MavenRepository method find.

File[] find(String groupId, String artifactId, VersionRange range) {
    String path = groupId.replace(".", "/");
    File vsdir = Processor.getFile(root, path);
    if (!vsdir.isDirectory())
        return null;
    vsdir = Processor.getFile(vsdir, artifactId);
    List<File> result = new ArrayList<File>();
    if (vsdir.isDirectory()) {
        String[] versions = vsdir.list();
        for (String v : versions) {
            String vv = Analyzer.cleanupVersion(v);
            if (Verifier.isVersion(vv)) {
                Version vvv = new Version(vv);
                if (range.includes(vvv)) {
                    File file = Processor.getFile(vsdir, v + "/" + artifactId + "-" + v + ".jar");
                    if (file.isFile())
                        result.add(file);
                    else
                        reporter.warning("Expected maven entry was not a valid file %s ", file);
                }
            } else {
                reporter.warning("Expected a version directory in maven: dir=%s raw-version=%s cleaned-up-version=%s", vsdir, vv, v);
            }
        }
    } else
        return null;
    return result.toArray(new File[0]);
}
Also used : Version(aQute.bnd.version.Version) ArrayList(java.util.ArrayList) File(java.io.File)

Example 63 with Version

use of aQute.bnd.version.Version in project bnd by bndtools.

the class JustAnotherPackageManager method update.

public void update(UpdateMemo memo) throws Exception {
    ArtifactData target = put(memo.best.urls.iterator().next());
    memo.current.version = new Version(memo.best.version);
    target.sync();
    memo.current.sha = target.sha;
    // memo.current.dependencies = target.dependencies;
    // memo.current.dependencies.add((new File(repoDir,
    // Hex.toHexString(target.sha))).getCanonicalPath());
    // memo.current.runbundles = target.runbundles;
    // memo.current.description = target.description;
    memo.current.time = target.time;
    if (memo.current instanceof ServiceData) {
        Service service = getService((ServiceData) memo.current);
        service.remove();
        createService((ServiceData) memo.current, true);
        IO.delete(new File(IO.getFile(serviceDir, memo.current.name), "data"));
        storeData(new File(IO.getFile(serviceDir, memo.current.name), "data"), memo.current);
    } else {
        platform.deleteCommand(memo.current);
        createCommand(memo.current, false);
        IO.delete(IO.getFile(commandDir, memo.current.name));
        storeData(IO.getFile(commandDir, memo.current.name), memo.current);
    }
}
Also used : Version(aQute.bnd.version.Version) ExecutorService(java.util.concurrent.ExecutorService) JarFile(java.util.jar.JarFile) IO.createTempFile(aQute.lib.io.IO.createTempFile) File(java.io.File)

Example 64 with Version

use of aQute.bnd.version.Version in project bnd by bndtools.

the class OBRTest method testVersions.

public static void testVersions() throws Exception {
    SortedSet<Version> result = obr.versions("name.njbartlett.osgi.emf.minimal");
    assertEquals(2, result.size());
    assertEquals(new Version("2.6.1.v20100914-1218"), result.first());
    assertEquals(new Version("2.7.0.201104130744"), result.last());
}
Also used : Version(aQute.bnd.version.Version)

Example 65 with Version

use of aQute.bnd.version.Version in project bnd by bndtools.

the class TestCompressedObrRepo method testVersions.

public static void testVersions() throws Exception {
    SortedSet<Version> result = obr.versions("name.njbartlett.osgi.emf.minimal");
    assertEquals(2, result.size());
    assertEquals(new Version("2.6.1.v20100914-1218"), result.first());
    assertEquals(new Version("2.7.0.201104130744"), result.last());
}
Also used : Version(aQute.bnd.version.Version)

Aggregations

Version (aQute.bnd.version.Version)171 File (java.io.File)67 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)29 ArrayList (java.util.ArrayList)21 Attrs (aQute.bnd.header.Attrs)19 MavenVersion (aQute.bnd.version.MavenVersion)19 HashMap (java.util.HashMap)18 IOException (java.io.IOException)17 Jar (aQute.bnd.osgi.Jar)16 Workspace (aQute.bnd.build.Workspace)13 Project (aQute.bnd.build.Project)12 RevisionRef (aQute.service.library.Library.RevisionRef)12 Matcher (java.util.regex.Matcher)12 Parameters (aQute.bnd.header.Parameters)11 VersionRange (aQute.bnd.version.VersionRange)11 SortedList (aQute.lib.collections.SortedList)9 Processor (aQute.bnd.osgi.Processor)8 ResourceDescriptor (aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)8 FileNotFoundException (java.io.FileNotFoundException)8 LinkedHashMap (java.util.LinkedHashMap)8