Search in sources :

Example 51 with Description

use of aQute.lib.getopt.Description in project bnd by bndtools.

the class bnd method _profile.

@Description("Profile management. A profile is a JAR that only contains packages and capabilities")
public void _profile(ProfileOptions options) throws Exception {
    Profiles profiles = new Profiles(this, options);
    CommandLine cmd = options._command();
    cmd.subCmd(options, profiles);
    getInfo(profiles);
}
Also used : CommandLine(aQute.lib.getopt.CommandLine) Description(aQute.lib.getopt.Description)

Example 52 with Description

use of aQute.lib.getopt.Description in project bnd by bndtools.

the class bnd method _action.

@Description("Execute an action on a repo, or if no name is give, list the actions")
public void _action(ActionOptions opts) throws Exception {
    Project project = getProject(opts.project());
    if (project == null) {
        error("Not in a project directory");
        return;
    }
    Glob filter = opts.filter();
    if (filter == null)
        filter = new Glob("*");
    List<Actionable> actionables = project.getPlugins(Actionable.class);
    if (actionables.isEmpty()) {
        error("No actionables in [%s]", project.getPlugins());
        return;
    }
    for (Actionable o : actionables) {
        if (filter.matcher(o.title()).matches()) {
            logger.debug("actionable {} - {}", o, o.title());
            Map<String, Runnable> map = o.actions();
            if (map != null) {
                if (opts._arguments().isEmpty()) {
                    out.printf("# %s%n", o.title());
                    if (opts.tooltip() && o.tooltip() != null) {
                        out.printf("%s%n", o.tooltip());
                    }
                    out.printf("## actions%n");
                    for (String entry : map.keySet()) {
                        out.printf("  %s%n", entry);
                    }
                } else {
                    for (String entry : opts._arguments()) {
                        Runnable r = map.get(entry);
                        if (r != null) {
                            r.run();
                        }
                    }
                }
            }
        }
    }
    getInfo(project);
}
Also used : Project(aQute.bnd.build.Project) Actionable(aQute.bnd.service.Actionable) Glob(aQute.libg.glob.Glob) Description(aQute.lib.getopt.Description)

Example 53 with Description

use of aQute.lib.getopt.Description in project bnd by bndtools.

the class bnd method _macro.

/**
	 * Show the value of a macro
	 * 
	 * @throws Exception
	 */
@Description("Show macro value")
public void _macro(macroOptions options) throws Exception {
    Project project = getProject(options.project());
    if (project == null) {
        messages.NoProject();
        return;
    }
    StringBuilder sb = new StringBuilder();
    Macro r = project.getReplacer();
    getInfo(project);
    String del = "";
    for (String s : options._arguments()) {
        if (!s.startsWith("${")) {
            s = "${" + s;
        }
        if (!s.endsWith("}")) {
            s += "}";
        }
        s = s.replace(':', ';');
        String p = r.process(s);
        sb.append(del);
        sb.append(p);
        del = " ";
    }
    getInfo(project);
    err.println(sb);
}
Also used : Project(aQute.bnd.build.Project) Macro(aQute.bnd.osgi.Macro) Description(aQute.lib.getopt.Description)

Example 54 with Description

use of aQute.lib.getopt.Description in project bnd by bndtools.

the class bnd method _debug.

/**
	 * Printout all the variables in scope.
	 * 
	 * @throws Exception
	 */
@SuppressWarnings("unchecked")
@Description("Show a lot of info about the project you're in")
public void _debug(debugOptions options) throws Exception {
    Project project = getProject(options.project());
    Justif justif = new Justif(120, 40, 50, 52, 80);
    logger.debug("using {}", project);
    Processor target = project;
    if (project != null) {
        Workspace ws = project.getWorkspace();
        ws.checkStructure();
        getInfo(project.getWorkspace());
        report(justif, "Workspace", project.getWorkspace());
        report(justif, "Project", project);
        if (project.getSubBuilders() != null)
            for (Builder sub : project.getSubBuilders()) {
                report(justif, "Sub-Builder", sub);
                getInfo(sub);
            }
        for (File file : project.getBase().listFiles()) {
            if (file.getName().endsWith(Constants.DEFAULT_BNDRUN_EXTENSION)) {
                Run run = Workspace.getRun(file);
                if (run == null) {
                    error("No such run file %s", file);
                } else {
                    report(justif, "bndrun", run);
                    getInfo(run);
                }
            }
        }
        if (options.flattened()) {
            @SuppressWarnings("rawtypes") Map fp = project.getFlattenedProperties();
            Justif j = new Justif(140, 40, 44, 48, 100);
            j.table(fp, "-");
            out.println(j.wrap());
        }
        getInfo(project.getWorkspace());
        getInfo(project);
    } else
        err.println("No project");
}
Also used : Project(aQute.bnd.build.Project) Processor(aQute.bnd.osgi.Processor) Justif(aQute.lib.justif.Justif) Builder(aQute.bnd.osgi.Builder) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Run(aQute.bnd.build.Run) File(java.io.File) MultiMap(aQute.lib.collections.MultiMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Workspace(aQute.bnd.build.Workspace) Description(aQute.lib.getopt.Description)

Example 55 with Description

use of aQute.lib.getopt.Description in project bnd by bndtools.

the class bnd method _version.

/**
	 * Show the version of this bnd
	 * 
	 * @throws IOException
	 */
@Description("Show version information about bnd")
public void _version(versionOptions o) throws IOException {
    if (!o.xtra()) {
        Analyzer a = new Analyzer();
        out.println(a.getBndVersion());
        a.close();
        return;
    }
    Enumeration<URL> e = getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
    while (e.hasMoreElements()) {
        URL u = e.nextElement();
        Manifest m = new Manifest(u.openStream());
        String bsn = m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
        if (bsn != null && bsn.equals("biz.aQute.bnd")) {
            Attributes attrs = m.getMainAttributes();
            long lastModified = 0;
            try {
                lastModified = Long.parseLong(attrs.getValue(Constants.BND_LASTMODIFIED));
            } catch (Exception ee) {
            // Ignore
            }
            out.printf("%-40s %s\n", "Version", attrs.getValue(Constants.BUNDLE_VERSION));
            if (lastModified > 0)
                out.printf("%-40s %s\n", "From", new Date(lastModified));
            Parameters p = OSGiHeader.parseHeader(attrs.getValue(Constants.BUNDLE_LICENSE));
            for (String l : p.keySet()) out.printf("%-40s %s\n", "License", p.get(l).get("description"));
            out.printf("%-40s %s\n", "Copyright", attrs.getValue(Constants.BUNDLE_COPYRIGHT));
            out.printf("%-40s %s\n", "Git-SHA", attrs.getValue("Git-SHA"));
            out.printf("%-40s %s\n", "Git-Descriptor", attrs.getValue("Git-Descriptor"));
            out.printf("%-40s %s\n", "Sources", attrs.getValue("Bundle-SCM"));
            return;
        }
    }
    error("Could not locate version");
}
Also used : Parameters(aQute.bnd.header.Parameters) Attributes(java.util.jar.Attributes) Analyzer(aQute.bnd.osgi.Analyzer) Manifest(java.util.jar.Manifest) PomFromManifest(aQute.bnd.maven.PomFromManifest) URL(java.net.URL) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) ZipException(java.util.zip.ZipException) Date(java.util.Date) Description(aQute.lib.getopt.Description)

Aggregations

Description (aQute.lib.getopt.Description)63 File (java.io.File)31 Jar (aQute.bnd.osgi.Jar)14 Project (aQute.bnd.build.Project)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)12 Instructions (aQute.bnd.osgi.Instructions)10 CommandLine (aQute.lib.getopt.CommandLine)10 Justif (aQute.lib.justif.Justif)8 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 Workspace (aQute.bnd.build.Workspace)7 PomFromManifest (aQute.bnd.maven.PomFromManifest)7 Service (aQute.jpm.lib.Service)7 Manifest (java.util.jar.Manifest)7 FileResource (aQute.bnd.osgi.FileResource)6 Resource (aQute.bnd.osgi.Resource)6 Analyzer (aQute.bnd.osgi.Analyzer)5 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)5 CommandData (aQute.jpm.lib.CommandData)5 ServiceData (aQute.jpm.lib.ServiceData)5