Package aQute.service.library.Library

Examples of aQute.service.library.Library.Revision


    String id = bsn + "-" + version;
    if (notfoundref.contains(id))
      return null;

    if (isSha(bsn) && version.equals(Version.LOWEST)) {
      Revision r = getRevision(new Coordinate(bsn));
      if (r == null)
        return null;

      return new RevisionRef(r);
    }
View Full Code Here


      if (!m.matches()) {
        reporter.trace("not a proper url to drop " + uri);
        return false;
      }

      Revision revision = getRevision(new Coordinate(m.group(1), m.group(2), m.group(3), m.group(4)));
      if (revision == null) {
        reporter.error("no revision found for %s", uri);
        return false;
      }
View Full Code Here

      if (!m.matches()) {
        return null;
      }

      Set<ResourceDescriptor> resources = new HashSet<ResourceDescriptor>();
      Revision revision = getRevision(new Coordinate(m.group(1), m.group(2), m.group(3), m.group(4)));

      if (revision != null) {
        ResourceDescriptor rd = createResourceDescriptor(new RevisionRef(revision));
        resources.add(rd);
        if (includeDependencies) {
View Full Code Here

          refs.remove(ref);
        else {
          // missing!
          reporter.trace("Missing " + c.getBundleSymbolicName());
          Coordinate coord = new Coordinate(c.getBundleSymbolicName());
          Revision rev = library.getRevisionByCoordinate(coord);
          if (rev != null) {
            index.addRevision(new RevisionRef(rev));
          } else
            System.out.printf("not found %s\n", c);
        }
View Full Code Here

          throw new IllegalArgumentException("Indicated SHA does not match input stream");

        depo.sha = sha;
        FileInputStream fin = new FileInputStream(f);
        try {
          Revision r = null; // = library.deposit(depo, fin);
          if (r == null)
            throw new IllegalArgumentException("No result returned");

          if (!Arrays.equals(r._id, sha))
            throw new IllegalArgumentException("Mismatch in shas " + Hex.toHexString(r._id) + "!="
View Full Code Here

    String id = bsn + "-" + version;
    if (notfoundref.contains(id))
      return null;

    if (isSha(bsn) && version.equals(Version.LOWEST)) {
      Revision r = library.getRevision(Library.SHA_GROUP + ":" + bsn + "@0.0.0");
      if (r == null)
        return null;

      return new RevisionRef(r);
    }
View Full Code Here

   * @param bsn
   * @param version
   * @throws Exception
   */
  private void wrap(String bsn, Version version) throws Exception {
    Revision r = library.getRevision(Library.OSGI_GROUP + ":" + bsn + "@" + version.toString());
    if (r == null)
      return;

    Jar jar = new Jar(get(bsn, version, null));
    Formatter f = new Formatter();
    Analyzer an = new Analyzer();
    try {
      an.setJar(jar);
      an.analyze();

      f.format("# Generated bnd wrapper for           %s:%s@%s\n", r.groupId, r.artifactId, r.version);
      f.format("# Recipe by                           ${global;name}\n\n");

      if (an.getBundleSymbolicName() != null) {
        f.format("#\n# ALREADY AN OSGI BUNDLE!!!\n#\n");
      }

      Manifest m = jar.getManifest();
      if (m != null) {
        String del = "# From original manifest\n";
        boolean yes = false;
        for (Entry<Object,Object> e : m.getMainAttributes().entrySet()) {
          yes = true;
          String key = e.getKey().toString();
          if ("Manifest-Version".equalsIgnoreCase(key) || "Bundle-ManifestVersion".equalsIgnoreCase(key)
              || key.startsWith("Bnd") || key.startsWith("Created"))
            continue;

          f.format("%s%-40s: %s", del, key, e.getValue());

          del = "\n";
        }
        if (yes)
          f.format("\n\n# End of original manifest");
        f.format("\n\n");
      }

      if (r.description != null)
        f.format("Bundle-Description:                   %s %s\\\n ${disclaimer}\n", r.title == null ? ""
            : r.title, r.description);
      else
        f.format("Bundle-Description: ##########################################################");

      String v = r.baseline;
      if (r.qualifier != null)
        v += "." + r.qualifier;

      f.format("Bundle-Version:                       %s\n", v);

      if (r.icon != null)
        f.format("Bundle-Icon:                          %s\n", r.icon);

      f.format("\n#\n# Coordinates\n#\n");
      f.format("JPM-From:                             sha:%s@0.0.0;coordinates=%s;bsn=%s\n",
          Hex.toHexString(r._id), getCoordinates(r), r.bsn);
      f.format("JPM-URL:                              https://jpm4j.org/#/p/%s/%s/%s/%s\n", r.groupId,
          r.artifactId, r.classifier == null ? "" : r.classifier, r.version);
      f.format("Include-Resource:                     @${repo;%s;0.0.0}\n", Hex.toHexString(r._id));

      if (r.docUrl != null)
        f.format("Bundle-DocURL:                        %s\n", r.docUrl);

      if (r.organization != null && r.organization.name != null) {
        f.format("Bundle-Vendor:                        %s\n", r.organization.name);
      }

      if (r.organization != null && r.organization.url != null) {
        f.format("Bundle-ContactAddress:                        %s\n", r.organization.url);
      }

      String del = "Bundle-License:                   ";
      for (License license : r.licenses) {
        f.format("%s %s", del, license.name);
        if (license.url != null)
          f.format(";url='%s'", license.url);
        if (license.comments != null)
          f.format(";description='%s'", license.comments);

        del = ", \\\n   ";
      }
      f.format("\n\n");

      del = "Bundle-Developers: \\\n   ";
      for (Developer dev : r.developers) {
        f.format("%s '%s'", del, dev.name);
        if (dev.email != null)
          f.format(";email='%s'", dev.email);

        if (dev.roles != null) {
          ExtList<String> el = new ExtList<String>(dev.roles);
          if (!el.isEmpty())
            f.format(";roles='%s'", el.join());
        }
        del = ", \\\n   ";
      }
      f.format("\n\n");

      del = "Bundle-Contributors: \\\n   ";
      for (Contributor dev : r.contributors) {
        f.format("%s %s", del, dev.name);
        if (dev.email != null)
          f.format(";email='%s'", dev.email);

        if (dev.roles != null) {
          ExtList<String> el = new ExtList<String>(dev.roles);
          if (!el.isEmpty())
            f.format(";roles='%s'", el.join());
        }
        del = ", \\\n   ";
      }
      f.format("\n\n");

      f.format("Export-Package: ");

      del = "";
      for (Entry<PackageRef,Attrs> pr : an.getContained().entrySet()) {
        f.format("%s\\\n  %s", del, pr.getKey().getFQN());
        if (pr.getValue().containsKey("version")) {
          f.format(";version=%s", pr.getValue().get("version"));
        } else {
          f.format(";version=100.0.0;provide:=true");
        }
        del = ",";
      }
      f.format("\n\n");
      f.format("#\n# Remove after inspection:\n\nImport-Package: ");

      del = "";
      for (Entry<PackageRef,Attrs> pr : an.getReferred().entrySet()) {
        if (pr.getKey().isJava() || pr.getKey().isMetaData())
          continue;

        f.format("%s\\\n  %s", del, pr.getKey().getFQN());
        if (pr.getValue().containsKey("version")) {
          f.format(";version='%s'", pr.getValue().get("version"));
        }
        del = ",";
      }
      f.format("\n\n");

      f.format("-buildpath:");
      del = " \\\n    ";

      for (Requirement req : r.requirements) {
        String name = req.name == null ? (String) req.ps.get("name:") : req.name;
        if ("x-maven".equals(req.ns) && name != null) {
          Matcher matcher = COORDINATE_P.matcher(name);
          if (matcher.matches()) {
            String g = matcher.group(1);
            String a = matcher.group(2);
            String vv = matcher.group(3);

            Revision dep = library.getRevision(g + ":" + a + "@" + vv);
            if (dep == null) {
              f.format("%s%s.%s;version=%s", del, g, a, vv);
            } else {
              f.format("%s%s;version=%s", del, r.bsn, vv);
            }
View Full Code Here

  public boolean dropTarget(URI uri) throws Exception {
    Matcher m = JPM_REVISION_URL_PATTERN.matcher(uri.toString());
    if (!m.matches())
      return false;

    Revision revision = library.getRevision(m.group(1), m.group(2), m.group(3), m.group(4));
    if (revision == null)
      return false;

    Library.RevisionRef resource = index.getRevisionRef(revision._id);
    if (resource != null)
View Full Code Here

    Matcher m = JPM_REVISION_URL_PATTERN.matcher(url.toString());
    if (!m.matches())
      return null;

    Set<ResourceDescriptor> resources = new HashSet<ResourceDescriptor>();
    Revision revision = library.getRevision(m.group(1), m.group(2), m.group(3), m.group(4));
    if (revision != null) {
      ResourceDescriptor rd = createResourceDescriptor(new RevisionRef(revision));
      resources.add(rd);
      if (includeDependencies) {
        for (RevisionRef dependency : library.getClosure(revision._id, false)) {
View Full Code Here

        coordinates += ":" + r.classifier;

      if (r.groupId.equals(Library.SHA_GROUP))
        continue;

      Revision current = programs.get(coordinates);
      if (current == null)
        programs.put(coordinates, r);
      else {
        // who is better?
        if (compare(r, current) >= 0)
View Full Code Here

TOP

Related Classes of aQute.service.library.Library.Revision

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.