Package aQute.bnd.plugin

Examples of aQute.bnd.plugin.Activator


    /**
     * @see IActionDelegate#run(IAction)
     */
    public void run(IAction action) {
        Activator activator = Activator.getDefault();

        try {
            if (locations != null) {
                for (int i = 0; i < locations.length; i++) {
                    try {
                        File mf = locations[i].getLocation().toFile();
                        if (mf.getName().equals(Project.BNDFILE)) {
                            Project project = Workspace.getProject(mf
                                    .getParentFile());
                            File[] files = project.build();
                            String target = "";
                            if ( files != null ) {
                                for ( File f : files ) {
                                    target += f + " ";
                                   
                                }
                            }
                            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);
                    }
                    locations[i].getParent().refreshLocal(1, null);
                }
            }
        } catch (Exception e) {
            activator.error("Error in bnd", e);
        }
    }
View Full Code Here

TOP

Related Classes of aQute.bnd.plugin.Activator

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.