Package aQute.lib.osgi

Examples of aQute.lib.osgi.Jar


        builder.mergeProperties(env, false);

        builder.setClasspath(classpath);
        // builder.setSourcepath(sourcepath);

        Jar jar = builder.build();

        convertErrors("BND: ", builder.getErrors());
        convertWarnings("BND: ", builder.getWarnings());

        Attributes main = jar.getManifest().getMainAttributes();
        String expHeader = main.getValue(Constants.EXPORT_PACKAGE);
        log.verbose("BND exports: " + expHeader);

        augmentImports(builder, jar, bundle);

        if (log != null)
        {
            for (String warn : warnings)
            {
                log.warn(warn);
            }
        }

        if (!errors.isEmpty())
        {
            throw new Exception(errors.toString());
        }

        boolean modified = false;
        File output = new File(dest);

        if (!output.exists() || force || (output.lastModified() <= jar.lastModified())
            || (output.lastModified() <= project.getLastModified()))
        {
            modified = true;
            // jar.write(dest) catches and ignores IOException
            OutputStream out = new FileOutputStream(dest);
            jar.write(out);
            out.close();
            jar.close();
        }

        builder.close();

        return modified;
View Full Code Here


          b.setProperty("Bundle-SymbolicName", bsn);
          b.setProperty("Bundle-Version", v);
          for (int i = 0; i < headers.length; i += 2) {
              b.setProperty(headers[i], headers[i + 1]);
          }
          Jar jar = b.build();
          jar.getManifest(); // Not sure whether this is needed...
          jar.write(f);
        } finally {
          b.close();
        }
    }
View Full Code Here

   Jar[] cp = getClasspath();
   builder.setProperties(properties);
   builder.setClasspath(cp);
   builder.build();
   Jar jar = builder.getJar();
   doMavenMetadata(jar);
   builder.setJar(jar);
   List errors = builder.getErrors();
   List warnings = builder.getWarnings();
View Full Code Here

  */
private Jar[] getClasspath() throws ZipException, IOException {
  List list = new ArrayList();
 
  if (outputDirectory != null && outputDirectory.exists()) {
    list.add(new Jar(".", outputDirectory));
  }
  Set artifacts = project.getArtifacts();
  for (Iterator it = artifacts.iterator(); it.hasNext();) {
   Artifact artifact = (Artifact) it.next();
   if (Artifact.SCOPE_COMPILE.equals(artifact.getScope())
     || Artifact.SCOPE_SYSTEM.equals(artifact.getScope())
     || Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) {
    Jar jar = new Jar(artifact.getArtifactId(), artifact.getFile());
    list.add(jar);
   }
  }
  Jar[] cp = new Jar[list.size()];
  list.toArray(cp);
View Full Code Here

        } catch (IOException e) {
            log.warn("Unable to build OSGI Bundle for Indexed Referenced Site "+config.getName(),e);
            builder.close();
            return;
        }
        Jar jar;
        try {
            jar = builder.build();
        } catch (Exception e) {
            log.warn("Unable to build OSGI Bundle for Indexed Referenced Site "+config.getName(),e);
      return;
    } finally {
      builder.close();
    }
        try {
            jar.write(new File(config.getDistributionFolder(),
                CONFIG_PACKAGE+config.getName()+"-1.0.0.jar"));
        } catch (Exception e) {
            log.warn("Unable to write OSGI Bundle for Indexed Referenced Site "+config.getName(),e);
        }
    }
View Full Code Here

            builder.addClasspath(new File(config.getDestinationFolder(),CONFIG_ROOT));
        } catch (IOException e) {
            log.warn("Unable to build OSGI Bundle for Indexed Referenced Site "+config.getName(),e);
            return;
        }
        Jar jar;
        try {
            jar = builder.build();
        } catch (Exception e) {
            log.warn("Unable to build OSGI Bundle for Indexed Referenced Site "+config.getName(),e);
            return;
        }
        try {
            jar.write(new File(config.getDistributionFolder(),
                CONFIG_PACKAGE+config.getName()+"-1.0.0.jar"));
        } catch (Exception e) {
            log.warn("Unable to write OSGI Bundle for Indexed Referenced Site "+config.getName(),e);
        }
    }
View Full Code Here

      return result;
  }

    public boolean analyzeJar(Analyzer analyzer) throws Exception {
        Jar jar = analyzer.getJar();
        Map<String, Resource> resources = jar.getResources();

        Pattern[] patterns = getSourcePatterns(analyzer);

        for (Entry<String, Resource> entry : resources.entrySet()) {
            String path = entry.getKey();
View Full Code Here

          File warFile = new File(new URL(warUrl).getPath());
          if (warFile.isFile() && warUrl.endsWith(".war"))
            return true;
          // If the war file is a directory, check if a bundle with
          // symbolic name.
          Jar jar = new Jar(warFile.getAbsolutePath(), warFile);
          Manifest manifest = jar.getManifest();
          String symbolicName = manifest.getMainAttributes()
              .getValue(Constants.BUNDLE_SYMBOLICNAME);
          if (StringUtils.isEmpty(symbolicName))
            return true;
        } catch (Exception e) {
View Full Code Here

     */

    // If the web bundle has its symbolic name and context path in
    // MANIFEST.MF file, use them at first.
    URL warURL = new URL(warUri);
    Jar jar = new Jar(warURL.getPath(), new File(warURL.getPath()));
    Manifest manifest = jar.getManifest();
    String symbolicName = manifest.getMainAttributes().getValue(
        Constants.BUNDLE_SYMBOLICNAME);
    String contextPath = manifest.getMainAttributes().getValue(
        "Web-ContextPath");
    if (symbolicName != null && symbolicName.trim().length() > 0)
      instructions.put(Constants.BUNDLE_SYMBOLICNAME, symbolicName);
    if (contextPath != null && contextPath.trim().length() > 0)
      instructions.put("Web-ContextPath", contextPath);

    // OSGi-Spec 128.3.1 WAB Definition
    // The Context Path must always begin with a forward slash ( ?/?).
    if (instructions.get("Web-ContextPath") != null) {
      String ctxtPath = (String) instructions.get("Web-ContextPath");
      if (!ctxtPath.startsWith("/")) {
        ctxtPath = "/" + ctxtPath;
        instructions.setProperty("Web-ContextPath", ctxtPath);
      }
    }
    // If not found bundle symblic name, use default.
    if (instructions.get(Constants.BUNDLE_SYMBOLICNAME) == null) {
      String defSymblicName = jar.getSource().getName();
      defSymblicName = defSymblicName.replaceAll("[^a-zA-Z_0-9.-]", "_")
          .replaceAll("(^|\\.)(\\d+)", "$1_$2");
      instructions.put(Constants.BUNDLE_SYMBOLICNAME, defSymblicName);
    }

View Full Code Here

    // LOG.debug( "Creating bundle for [" + jarInfo + "]" );
    // LOG.debug( "Overwrite mode: " + overwriteMode );
    // LOG.trace( "Using instructions " + instructions );

    // Do support jar as directory.
    Jar jar = null;
    URL jarURL = new URL(jarInfo);
    if (jarURL.getProtocol().equals("file")) {
      File jarFileOrDir = new File(jarURL.getPath());
      if (jarFileOrDir.isDirectory())
        jar = new Jar(jarURL.getPath(), jarFileOrDir);

    }
    if (jar == null)
      jar = new Jar("dot", jarInputStream);
    final Manifest manifest = jar.getManifest();

    // Make the jar a bundle if it is not already a bundle
    if (manifest == null
        || OverwriteMode.KEEP != overwriteMode
        || (manifest.getMainAttributes().getValue(
View Full Code Here

TOP

Related Classes of aQute.lib.osgi.Jar

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.