use of aQute.bnd.build.Project in project bnd by bndtools.
the class bnd method _export.
public void _export(ExportOptions opts) throws Exception {
Project project = getProject(opts.project());
if (project == null) {
error("No project");
return;
}
// temporary
project.getWorkspace().addBasicPlugin(new SubsystemExporter());
List<Exporter> exporters = project.getPlugins(Exporter.class);
Exporter exporter = null;
for (Exporter e : exporters) {
String[] types = e.getTypes();
for (String type : types) {
if (type.equals(opts.exporter()))
;
}
}
for (String bndrun : opts._arguments()) {
File f = getFile(bndrun);
if (!f.isFile()) {
error("No such file: %s", f);
continue;
}
Run run = new Run(project.getWorkspace(), getBase(), f);
run.getSettings(this);
Parameters exports = new Parameters();
List<String> types = opts.exporter();
if (types != null) {
for (String type : types) {
exports.putAll(new Parameters(type, this));
}
} else {
String exportTypes = run.getProperty(Constants.EXPORTTYPE);
exports.putAll(new Parameters(exportTypes, this));
}
for (Entry<String, Attrs> e : exports.entrySet()) {
logger.debug("exporting {} to {} with {}", run, e.getKey(), e.getValue());
Map.Entry<String, Resource> result = run.export(e.getKey(), e.getValue());
getInfo(run);
if (result != null && isOk()) {
String name = result.getKey();
File output = new File(project.getTarget(), opts.output() == null ? name : opts.output());
if (output.isDirectory())
output = new File(output, name);
IO.mkdirs(output.getParentFile());
logger.debug("Got a result for {}, store in {}", e.getKey(), output);
IO.copy(result.getValue().openInputStream(), output);
}
}
}
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class bnd method __par.
/**
* Lets see if we can build in parallel
*
* @throws Exception
*/
public void __par(final ParallelBuildOptions options) throws Exception {
ExecutorService pool = Executors.newCachedThreadPool();
final AtomicBoolean quit = new AtomicBoolean();
try {
final Project p = getProject(options.project());
final Workspace workspace = p == null || options.full() ? Workspace.getWorkspace(getBase()) : p.getWorkspace();
if (!workspace.exists()) {
error("cannot find workspace");
return;
}
final Collection<Project> targets = p == null ? workspace.getAllProjects() : p.getDependson();
final Forker<Project> forker = new Forker<Project>(pool);
for (final Project dep : targets) {
forker.doWhen(dep.getDependson(), dep, new Runnable() {
public void run() {
if (!quit.get()) {
try {
dep.compile(false);
if (!quit.get())
dep.build();
if (!dep.isOk())
quit.set(true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
}
System.err.flush();
forker.start(20000);
for (Project dep : targets) {
getInfo(dep, dep + ": ");
}
if (p != null && p.isOk() && !options.full()) {
p.compile(options.test());
p.build();
if (options.test() && p.isOk())
p.test();
getInfo(p);
}
workspace.close();
} finally {
pool.shutdownNow();
}
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class bnd method _info.
@Description("Show key project variables")
public void _info(infoOptions options) throws Exception {
Project p = getProject(options.project());
if (p == null) {
messages.NoProject();
return;
}
boolean any = options.runbundles() || options.buildpath() || options.classpath() || options.dependsOn() || options.vmpath();
MultiMap<String, Object> table = new MultiMap<String, Object>();
if (any || options.runbundles()) {
table.addAll("Run", p.getRunbundles());
}
if (any || options.buildpath()) {
table.addAll("Build", p.getBuildpath());
}
if (any || options.buildpath()) {
table.addAll("Depends on", p.getDependson());
}
if (any || options.sourcepath()) {
table.addAll("Source", p.getSourcePath());
}
if (any || options.classpath()) {
table.addAll("Class path", p.getClasspath());
}
if (any || options.vmpath()) {
table.addAll("Run path", p.getRunpath());
}
printMultiMap(table);
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class bnd method _find.
public void _find(FindOptions options) throws Exception {
List<File> files = new ArrayList<File>();
List<String> args = options._arguments();
if (args.size() == 0) {
Project p = getProject();
if (p == null) {
error("This is not a project directory and you have specified no jar files ...");
return;
}
File output = p.getOutput();
if (output.exists()) {
files.add(output);
}
for (Container c : p.getBuildpath()) {
files.add(c.getFile());
}
} else {
for (String f : args) {
File file = getFile(f);
files.add(file);
}
}
for (File f : files) {
logger.debug("find {}", f);
try (Jar jar = new Jar(f)) {
Manifest m = jar.getManifest();
if (m != null) {
Domain domain = Domain.domain(m);
if (options.exports() != null) {
Parameters ep = domain.getExportPackage();
for (Glob g : options.exports()) {
for (Entry<String, Attrs> exp : ep.entrySet()) {
if (g.matcher(exp.getKey()).matches()) {
String v = exp.getValue().get(VERSION_ATTRIBUTE);
if (v == null)
v = "0";
out.printf(">%s: %s-%s%n", f.getPath(), exp.getKey(), v);
}
}
}
}
if (options.imports() != null) {
Parameters ip = domain.getImportPackage();
for (Glob g : options.imports()) {
for (Entry<String, Attrs> imp : ip.entrySet()) {
if (g.matcher(imp.getKey()).matches()) {
String v = imp.getValue().get(VERSION_ATTRIBUTE);
if (v == null)
v = "0";
out.printf("<%s: %s-%s%n", f.getPath(), imp.getKey(), v);
}
}
}
}
}
}
}
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class bnd method doRun.
private void doRun(List<String> args, boolean verify, String project) throws Exception {
Project run = null;
if (args.isEmpty()) {
run = getProject(project);
if (run == null) {
messages.NoProject();
return;
}
} else {
File f = getFile(args.get(0));
File dir = f.getParentFile();
File wsdir = dir.getParentFile();
if (wsdir == null) {
// We are in the filesystem root?? Create a standalone run.
run = Run.createRun(null, f);
} else {
Workspace workspace = Workspace.getWorkspaceWithoutException(wsdir);
run = Run.createRun(workspace, f);
}
}
verifyDependencies(run, verify, false);
try {
run.run();
} catch (Exception e) {
messages.Failed__(e, "Running " + run);
}
getInfo(run);
getInfo(run.getWorkspace());
}
Aggregations