Package aQute.lib.osgi

Examples of aQute.lib.osgi.Builder


                log.verbose("-----------------------------");
            }
            log.verbose("BND classpath: " + Arrays.asList(classpath));
        }

        Builder builder = new Builder();
        builder.setPedantic(true);
        builder.setProperties(spec);
        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


        }
    }

    /** Creates a bundle on disk, using the specified file, symbolic name and version. */
    private void createBundleOnDisk(File f, String bsn, String v, String... headers) throws Exception {
        Builder b = new Builder();
        try {
          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

   properties.put("project.build.directory", buildDirectory );
   properties.put("project.build.outputdirectory", outputDirectory );
  
   properties.putAll(instructions);
   Builder builder = new Builder();
   builder.setBase(baseDir);
   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();
   if (errors.size() > 0) {
    jarFile.delete();
    for (Iterator e = errors.iterator(); e.hasNext();) {
     String msg = (String) e.next();
     getLog().error(msg);
    }
    throw new MojoFailureException("Found errors, see log");
   }
   else {
    jarFile.getParentFile().mkdirs();
    builder.getJar().write(jarFile);
    project.getArtifact().setFile(jarFile);
   }
   for (Iterator w = warnings.iterator(); w.hasNext();) {
    String msg = (String) w.next();
    getLog().warn(msg);
View Full Code Here

        }
        return siteConfigDir;
    }
   
    public static void createBundle(IndexingConfig config){
        Builder builder = new Builder();
        builder.setProperty("Install-Path",
            FilenameUtils.separatorsToUnix(CONFIG_PATH) //see STANBOL-768
                + config.getName().toLowerCase());
        builder.setProperty(Builder.EXPORT_PACKAGE,CONFIG_PACKAGE+config.getName().toLowerCase());
        builder.setProperty(Builder.BUNDLE_CATEGORY, "Stanbol Data");
        builder.setProperty(Builder.BUNDLE_NAME, "Apache Stanbol Data: "+config.getName());
        builder.setProperty(Builder.CREATED_BY, "Apache Stanbol Entityhub Indexing Utils");
        builder.setProperty(Builder.BUNDLE_VENDOR, "Apache Stanbol (Incubating)");//TODO make configureable
        builder.setProperty(Builder.BUNDLE_VERSION, "1.0.0");
        builder.setProperty(Builder.BUNDLE_DESCRIPTION, "Bundle created for import of the referenced site "
            + config.getName() +" into the Apache Stanbol Entityhub");
        builder.setProperty(Builder.BUNDLE_SYMBOLICNAME, CONFIG_PACKAGE+config.getName().toLowerCase());
        try {
            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);
            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) {
View Full Code Here

        }
        return siteConfigDir;
    }
   
    public static void createBundle(IndexingConfig config){
        Builder builder = new Builder();
        builder.setProperty("Install-Path",
            FilenameUtils.separatorsToUnix(CONFIG_PATH) //see STANBOL-768
                + config.getName().toLowerCase());
        builder.setProperty(Builder.EXPORT_PACKAGE,CONFIG_PACKAGE+config.getName().toLowerCase());
        builder.setProperty(Builder.BUNDLE_CATEGORY, "Stanbol Data");
        builder.setProperty(Builder.BUNDLE_NAME, "Apache Stanbol Data: "+config.getName());
        builder.setProperty(Builder.CREATED_BY, "Apache Stanbol Entityhub Indexing Utils");
        builder.setProperty(Builder.BUNDLE_VENDOR, "Apache Stanbol (Incubating)");//TODO make configureable
        builder.setProperty(Builder.BUNDLE_VERSION, "1.0.0");
        builder.setProperty(Builder.BUNDLE_DESCRIPTION, "Bundle created for import of the referenced site "
            + config.getName() +" into the Apache Stanbol Entityhub");
        builder.setProperty(Builder.BUNDLE_SYMBOLICNAME, CONFIG_PACKAGE+config.getName().toLowerCase());
        try {
            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 {
View Full Code Here

        }
        return siteConfigDir;
    }
   
    public static void createBundle(IndexingConfig config){
        Builder builder = new Builder();
        builder.setProperty("Install-Path",CONFIG_PATH+config.getName().toLowerCase());
        builder.setProperty(Builder.EXPORT_PACKAGE,CONFIG_PACKAGE+config.getName().toLowerCase());
        builder.setProperty(Builder.BUNDLE_CATEGORY, "Stanbol Data");
        builder.setProperty(Builder.BUNDLE_NAME, "Apache Stanbol Data: "+config.getName());
        builder.setProperty(Builder.CREATED_BY, "Apache Stanbol Entityhub Indexing Utils");
        builder.setProperty(Builder.BUNDLE_VENDOR, "Apache Stanbol (Incubating)");//TODO make configureable
        builder.setProperty(Builder.BUNDLE_VERSION, "1.0.0");
        builder.setProperty(Builder.BUNDLE_DESCRIPTION, "Bundle created for import of the referenced site "
            + config.getName() +" into the Apache Stanbol Entityhub");
        builder.setProperty(Builder.BUNDLE_SYMBOLICNAME, CONFIG_PACKAGE+config.getName().toLowerCase());
        try {
            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 {
View Full Code Here

                                }
                            }
                            activator.report(true, true, project, "Building "
                                    + project, "Created files " + target );
                        } else {
                            Builder builder = setBuilder(activator,
                                    locations[i].getProject(), mf);

                            File cwd = mf.getAbsoluteFile().getParentFile();
                            File target;

                            builder.build();
                            String name = builder.getBsn() + ".jar";

                            Jar jar = builder.getJar();

                            String path = builder.getProperty("-output");
                            if (path == null) {
                                target = new File(cwd, name);
                            } else {
                                target = new File(path);
                                if (!target.isAbsolute())
                                    target = new File(cwd, path);
                                if (target.isDirectory()) {
                                    target = new File(target, name);
                                }
                            }

                            target.delete();
                            if (builder.getErrors().size() > 0) {
                                activator.error(builder.getErrors());
                            } else {
                                jar.write(target);

                                File copy = activator.getCopy();
                                if (copy != null) {
                                    copy = new File(copy, target.getName());
                                    jar.write(copy);
                                }
                                if (builder.getWarnings().size() > 0) {
                                    activator.warning(builder.getWarnings());
                                } else {
                                    if (activator.getReportDone()) {
                                        String p = target.getPath();
                                        if (p.startsWith(cwd.getAbsolutePath()))
                                            p = p
                                                    .substring(cwd
                                                            .getAbsolutePath()
                                                            .length() + 1);
                                        String msg = "Saved as " + p;
                                        if (copy != null)
                                            msg += " and copied to " + copy;
                                        activator.message(msg);
                                    }
                                }
                            }
                            builder.close();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        activator.error("While generating JAR " + locations[i],
                                e);
View Full Code Here

        }
    }

    static public Builder setBuilder(Activator activator, IProject project,
            File mf) throws Exception, IOException, FileNotFoundException {
        Builder builder = new Builder();
        builder.setPedantic(activator.isPedantic() || activator.isDebugging());

        // TODO of course we should get the classpath from
        // inside API ...
        File p = project.getLocation().toFile();

        // TODO for now we ignore the workspace and use the
        // project parent directory

        EclipseClasspath ecp = new EclipseClasspath(builder, p.getParentFile(),
                p);

        builder.setClasspath((File[]) ecp.getClasspath().toArray(new File[0]));
        builder
                .setSourcepath((File[]) ecp.getSourcepath()
                        .toArray(new File[0]));
        builder.setProperties(mf);
        return builder;
    }
View Full Code Here

TOP

Related Classes of aQute.lib.osgi.Builder

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.