Package aQute.bnd.osgi

Examples of aQute.bnd.osgi.Jar


          builder.setProperties(projectProperties);
        }

        builder.setClasspath(toFiles(classpath, "classpath"));
        builder.setSourcepath(toFiles(sourcepath, "sourcepath"));
        Jar jars[] = builder.builds();

        // Report both task failures and bnd build failures.
        boolean taskFailed = report();
        boolean bndFailed = report(builder);

        // Fail this build if failure is not ok and either the task failed or the bnd build failed.
        if (!failok && (taskFailed || bndFailed)) {
          throw new BuildException("bnd failed", new org.apache.tools.ant.Location(file.getAbsolutePath()));
        }

        for (int i = 0; i < jars.length; i++) {
          Jar jar = jars[i];
          String bsn = jar.getName();

          File base = file.getParentFile();
          File output = this.output;

          String path = builder.getProperty("-output");

          if (output == null) {
            if (path == null)
              output = getFile(base, bsn + ".jar");
            else {
              output = getFile(base, path);
            }
          } else if (output.isDirectory()) {
            if (path == null)
              output = getFile(this.output, bsn + ".jar");
            else
              output = getFile(this.output, path);
          } else if (output.isFile()) {
            if (files.size() > 1)
              messages.GotFileNeedDir_(output.getAbsoluteFile());
          }

          String msg = "";
          if (!output.exists() || output.lastModified() <= jar.lastModified()) {
            jar.write(output);
          } else {
            msg = "(not modified)";
          }
          trace(jar.getName() + " (" + output.getName() + ") " + jar.getResources().size() + " " + msg);
          report();
          jar.close();
        }
        builder.close();
      }
    }
    catch (Exception e) {
View Full Code Here


        analyzer.setProperty(Constants.BUNDLE_VERSION, version);
      }

      analyzer.calcManifest();

      Jar jar = analyzer.getJar();
      jar.write(outputJar);
      jar.close();
      analyzer.close();
    }
    catch (OsgiBuildException e) {
      throw e;
    }
View Full Code Here

            myReporter.warning("Can't read manifest: " + e.getMessage(), e, manifest);
          }
        }
      }

      Jar jar = builder.build();
      jar.setName(outputFile.getName());
      jar.write(outputFile);
      builder.close();
    }
    catch (Exception e) {
      throw new OsgiBuildException("Unexpected build error", e, null);
    }
View Full Code Here

          builder.setProperties(projectProperties);
        }

        builder.setClasspath(toFiles(classpath, "classpath"));
        builder.setSourcepath(toFiles(sourcepath, "sourcepath"));
        Jar jars[] = builder.builds();

        // Report both task failures and bnd build failures.
        boolean taskFailed = report();
        boolean bndFailed = report(builder);

        // Fail this build if failure is not ok and either the task failed or the bnd build failed.
        if (!failok && (taskFailed || bndFailed)) {
          throw new BuildException("bnd failed", new org.apache.tools.ant.Location(file.getAbsolutePath()));
        }

        for (int i = 0; i < jars.length; i++) {
          Jar jar = jars[i];
          String bsn = jar.getName();

          File base = file.getParentFile();
          File output = this.output;

          String path = builder.getProperty("-output");

          if (output == null) {
            if (path == null)
              output = getFile(base, bsn + ".jar");
            else {
              output = getFile(base, path);
            }
          } else if (output.isDirectory()) {
            if (path == null)
              output = getFile(this.output, bsn + ".jar");
            else
              output = getFile(this.output, path);
          } else if (output.isFile()) {
            if (files.size() > 1)
              messages.GotFileNeedDir_(output.getAbsoluteFile());
          }

          String msg = "";
          if (!output.exists() || output.lastModified() <= jar.lastModified()) {
            jar.write(output);
          } else {
            msg = "(not modified)";
          }
          trace(jar.getName() + " (" + output.getName() + ") " + jar.getResources().size() + " " + msg);
          report();
          jar.close();
        }
        builder.close();
      }
    }
    catch (Exception e) {
View Full Code Here

        // When
        InstallContext installContext = new InstallContext(null, installDir, false);
        jarInstaller.install(installContext, new ProcessConfig(), "1", installDir);

        // Then
        Manifest manifest = new Jar(new File(installDir, "lib/main.jar")).getManifest();
        assertEquals("org.apache.camel.camel-xstream", manifest.getMainAttributes().getValue("Bundle-SymbolicName"));
    }
View Full Code Here

     * Sets the executable class name in the given jar
     */
    protected void setMainClass(ProcessConfig config, File installDir, File jarFile, String id, String mainClass) throws Exception {
        File tmpFile = File.createTempFile("fuse-process-" + id, ".jar");
        Files.copy(jarFile, tmpFile);
        Jar jar = new Jar(tmpFile);
        Attributes attributes = jar.getManifest().getMainAttributes();
        attributes.putValue("Main-Class", mainClass);
        jar.write(jarFile);
    }
View Full Code Here

                                           final Map<String, Map<String, String>> extraImportPackages,
                                           final Set<String> actualImports,
                                           final VersionResolver versionResolver)
            throws Exception
    {
        Jar jar = createJar(jarInputStream,  instructions, jarInfo,
                            overwriteMode, embeddedResources, extraImportPackages,
                            actualImports, versionResolver);
        return createInputStream( jar );
    }
View Full Code Here

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

        final Jar 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( Analyzer.EXPORT_PACKAGE ) == null
                 && manifest.getMainAttributes().getValue( Analyzer.IMPORT_PACKAGE ) == null )
            )
        {
            // Do not use instructions as default for properties because it looks like BND uses the props
            // via some other means then getProperty() and so the instructions will not be used at all
            // So, just copy instructions to properties
            final Properties properties = new Properties();
            properties.putAll(instructions);

            properties.put("Generated-By-FAB-From", jarInfo);
            properties.put(Analyzer.PLUGIN, ANALYZER_PLUGIN_NAMES);

            final Analyzer analyzer = new Analyzer();
            analyzer.setJar(jar);
            analyzer.setProperties(properties);

            // now lets add all the new embedded jars
            for (Map.Entry<String, Object> entry : embeddedResources.entrySet()) {
                String path = entry.getKey();
                Object value = entry.getValue();
                Resource resource = toResource(value);
                if (resource != null) {
                    jar.putResource(path, resource);
                    try {
                        File file = toFile(value);
                        analyzer.addClasspath(file);
                    } catch (IOException e) {
                        LOG.warn("Failed to get File for " + value + ". " + e, e);
                    }
                }
            }


            if (manifest != null && OverwriteMode.MERGE == overwriteMode) {
                analyzer.mergeManifest(manifest);
            }
            checkMandatoryProperties(analyzer, jar, jarInfo);

            Manifest newManifest = analyzer.calcManifest();
            jar.setManifest( newManifest );

            Attributes main = jar.getManifest().getMainAttributes();

            // Hack to add back META-INF imports
            String importPackage = main.getValue(Analyzer.IMPORT_PACKAGE);
            for (Descriptors.PackageRef key : analyzer.getReferred().keySet()) {
                if (key.getFQN().startsWith("META-INF.")) {
View Full Code Here

TOP

Related Classes of aQute.bnd.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.