use of aQute.bnd.build.Workspace in project bnd by bndtools.
the class bnd method _runtests.
/**
* Run the tests from a prepared bnd file.
*
* @throws Exception
*/
@Description("Run OSGi tests and create report")
public void _runtests(runtestsOptions opts) throws Exception {
int errors = 0;
File cwd = new File("").getAbsoluteFile();
Workspace ws = new Workspace(cwd);
try {
File reportDir = getFile("reports");
IO.delete(reportDir);
Tag summary = new Tag("summary");
summary.addAttribute("date", new Date());
summary.addAttribute("ws", ws.getBase());
if (opts.reportdir() != null) {
reportDir = getFile(opts.reportdir());
}
IO.mkdirs(reportDir);
if (!reportDir.isDirectory())
error("reportdir must be a directory %s (tried to create it ...)", reportDir);
if (opts.title() != null)
summary.addAttribute("title", opts.title());
if (opts.dir() != null)
cwd = getFile(opts.dir());
if (opts.workspace() != null) {
ws.close();
ws = Workspace.getWorkspace(getFile(opts.workspace()));
}
// TODO check all the arguments
boolean hadOne = false;
try {
for (String arg : opts._arguments()) {
logger.debug("will run test {}", arg);
File f = getFile(arg);
errors += runtTest(f, ws, reportDir, summary);
hadOne = true;
}
if (!hadOne) {
// See if we had any, if so, just use all files in
// the current directory
File[] files = cwd.listFiles();
for (File f : files) {
if (f.getName().endsWith(".bnd")) {
errors += runtTest(f, ws, reportDir, summary);
}
}
}
} catch (Throwable e) {
if (isExceptions()) {
printExceptionSummary(e, out);
}
exception(e, "FAILURE IN RUNTESTS");
errors++;
}
if (errors > 0)
summary.addAttribute("errors", errors);
for (String error : getErrors()) {
Tag e = new Tag("error");
e.addContent(error);
}
for (String warning : getWarnings()) {
Tag e = new Tag("warning");
e.addContent(warning);
}
File r = getFile(reportDir, "summary.xml");
try (PrintWriter pw = IO.writer(r, UTF_8)) {
summary.print(0, pw);
}
if (errors != 0)
error("Errors found %s", errors);
} finally {
ws.close();
}
}
use of aQute.bnd.build.Workspace 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());
}
use of aQute.bnd.build.Workspace in project bnd by bndtools.
the class bnd method main.
public static void main(String[] args) throws Exception {
Workspace.setDriver(Constants.BNDDRIVER_BND);
Workspace.addGestalt(Constants.GESTALT_SHELL, null);
Workspace.addGestalt(Constants.GESTALT_INTERACTIVE, null);
Workspace ws = Workspace.findWorkspace(IO.work);
try (bnd main = new bnd()) {
// ws == null ? new bnd() : new bnd(ws);
main.start(args);
}
exitWithCode(0);
}
use of aQute.bnd.build.Workspace in project bndtools by bndtools.
the class BndEditor method loadEditModel.
private void loadEditModel() throws Exception {
// Create the bnd edit model and workspace
Workspace ws = Central.getWorkspaceIfPresent();
Project bndProject = Run.createRun(ws, inputFile);
model.setWorkspace(bndProject.getWorkspace());
model.setProject(bndProject);
// Load content into the edit model
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
// #1625: Ensure the IDocumentProvider is not null.
if (docProvider != null) {
IDocument document = docProvider.getDocument(getEditorInput());
try {
model.loadFrom(new IDocumentWrapper(document));
model.setBndResource(inputFile);
} catch (IOException e) {
logger.logError("Unable to load edit model", e);
}
for (int i = 0; i < getPageCount(); i++) {
Control control = getControl(i);
if (control instanceof ScrolledForm) {
ScrolledForm form = (ScrolledForm) control;
if (SYNC_MESSAGE.equals(form.getMessage())) {
form.setMessage(null, IMessageProvider.NONE);
}
}
}
}
}
});
}
use of aQute.bnd.build.Workspace in project bndtools by bndtools.
the class BndEditorPart method refresh.
@Override
public final void refresh() {
if (!Central.hasWorkspaceDirectory()) {
refreshFromModel();
} else {
Central.onWorkspaceInit(new Success<Workspace, Void>() {
@Override
public Promise<Void> call(Promise<Workspace> resolved) throws Exception {
try {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
refreshFromModel();
ScrolledForm form = getManagedForm().getForm();
if (BndEditor.SYNC_MESSAGE.equals(form.getMessage())) {
form.setMessage(null, IMessageProvider.NONE);
}
}
});
} catch (Exception e) {
}
return Promises.resolved(null);
}
});
}
super.refresh();
}
Aggregations