use of aQute.lib.getopt.Description in project bnd by bndtools.
the class bnd method _wrap.
/**
* Wrap a jar to a bundle.
*
* @throws Exception
*/
@Description("Wrap a jar")
public void _wrap(wrapOptions options) throws Exception {
List<File> classpath = Create.list();
File properties = getBase();
if (options.properties() != null) {
properties = getFile(options.properties());
}
if (options.classpath() != null)
for (String cp : options.classpath()) {
classpath.add(getFile(cp));
}
for (String j : options._arguments()) {
File file = getFile(j);
if (!file.isFile()) {
error("File does not exist %s", file);
continue;
}
try (Analyzer wrapper = new Analyzer(this)) {
wrapper.use(this);
for (File f : classpath) wrapper.addClasspath(f);
wrapper.setJar(file);
File outputFile = wrapper.getOutputFile(options.output());
if (outputFile.getCanonicalFile().equals(file.getCanonicalFile())) {
// #267: CommandLine wrap deletes target even if file equals
// source
error("Output file %s and source file %s are the same file, they must be different", outputFile, file);
return;
}
IO.delete(outputFile);
String stem = file.getName();
if (stem.endsWith(".jar"))
stem = stem.substring(0, stem.length() - 4) + ".bnd";
File p = getPropertiesFile(properties, file, stem);
if (p == null) {
wrapper.setImportPackage("*;resolution:=optional");
wrapper.setExportPackage("*");
warning("Using defaults for wrap, which means no export versions");
} else if (p.isFile())
wrapper.setProperties(p);
else {
error("No valid property file: %s", p);
}
if (options.bsn() != null)
wrapper.setBundleSymbolicName(options.bsn());
if (options.version() != null)
wrapper.setBundleVersion(options.version());
Manifest m = wrapper.calcManifest();
if (wrapper.isOk()) {
wrapper.getJar().setManifest(m);
wrapper.save(outputFile, options.force());
}
getInfo(wrapper, file.toString());
}
}
}
use of aQute.lib.getopt.Description in project bnd by bndtools.
the class bnd method _verify.
/**
* Verify jars.
*
* @throws Exception
*/
@Description("Verify jars")
public void _verify(verifyOptions opts) throws Exception {
for (String path : opts._arguments()) {
File f = getFile(path);
if (!f.isFile()) {
error("No such file: %s", f);
} else {
Jar jar = new Jar(f);
if (jar.getManifest() == null || jar.getBsn() == null)
error("Not a bundle %s", f);
else {
Verifier v = new Verifier(jar);
getInfo(v, f.getName());
v.close();
}
jar.close();
}
}
}
use of aQute.lib.getopt.Description in project bnd by bndtools.
the class bnd method _add.
@Description("Add a workspace, or a project or a plugin to the workspace")
public void _add(AddOptions opts) throws Exception {
List<String> args = opts._arguments();
String what = args.remove(0);
if ("project".equals(what)) {
Workspace ws = Workspace.findWorkspace(getBase());
if (ws == null) {
error("No workspace found from %s", getBase());
return;
}
for (String pname : args) {
ws.createProject(pname);
}
getInfo(ws);
return;
}
if ("workspace".equals(what)) {
for (String pname : args) {
File wsdir = getFile(pname);
ws = Workspace.createWorkspace(wsdir);
if (ws == null) {
error("Could not create workspace");
}
}
getInfo(ws);
return;
}
if ("plugin".equals(what)) {
Workspace ws = getWorkspace(getBase());
if (ws == null) {
error("No workspace found from %s", getBase());
return;
}
CommandLine cl = new CommandLine(this);
String help = cl.execute(new Plugins(this, ws), "add", new ExtList<String>(args));
if (help != null)
out.println(help);
getInfo(ws);
return;
}
}
use of aQute.lib.getopt.Description in project bnd by bndtools.
the class bnd method _maven.
/**
* Maven command
*
* @throws Exception
*/
@Description("Maven bundle command")
public void _maven(Options options) throws Exception {
MavenCommand mc = new MavenCommand(this);
mc.use(this);
mc.run(options._arguments().toArray(new String[0]), 1);
getInfo(mc);
}
use of aQute.lib.getopt.Description in project bnd by bndtools.
the class bnd method _clean.
@Description("Clean a project")
public void _clean(cleanOptions opts) throws Exception {
Project project = getProject(opts.project());
if (project == null) {
messages.NoProject();
return;
}
project.clean();
getInfo(project);
}
Aggregations