use of aQute.bnd.build.Workspace in project bnd by bndtools.
the class PomRepositoryTest method testBndPomRepoFileMissingParent.
public void testBndPomRepoFileMissingParent() throws Exception {
BndPomRepository bpr = new BndPomRepository();
Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
w.setBase(tmp);
bpr.setRegistry(w);
Map<String, String> config = new HashMap<>();
config.put("pom", "testdata/pomrepo/missing-parent.xml");
config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
config.put("releaseUrls", "https://repo1.maven.org/maven2/");
config.put("name", "test");
bpr.setProperties(config);
try {
bpr.list(null);
fail("Should throw IllegalArgumentException on missing parent pom.");
} catch (Exception iae) {
// This exception is expected!
}
}
use of aQute.bnd.build.Workspace in project bnd by bndtools.
the class PomRepositoryTest method testSearchRepoFailNoQuery.
public void testSearchRepoFailNoQuery() throws Exception {
BndPomRepository mcsr = new BndPomRepository();
Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
w.setBase(tmp);
mcsr.setRegistry(w);
Map<String, String> config = new HashMap<>();
config.put("name", "test");
try {
mcsr.setProperties(config);
fail();
} catch (Exception e) {
assertEquals("Neither pom, revision nor query property are set", e.getMessage());
}
}
use of aQute.bnd.build.Workspace in project bnd by bndtools.
the class PomRepositoryTest method testBndPomRepoFile.
public void testBndPomRepoFile() throws Exception {
BndPomRepository bpr = new BndPomRepository();
Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
w.setBase(tmp);
bpr.setRegistry(w);
Map<String, String> config = new HashMap<>();
config.put("pom", "testdata/pomrepo/simple.xml");
config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
config.put("releaseUrls", "https://repo1.maven.org/maven2/");
config.put("name", "test");
bpr.setProperties(config);
List<String> list = bpr.list(null);
assertNotNull(list);
assertEquals(1, list.size());
}
use of aQute.bnd.build.Workspace in project bndtools by bndtools.
the class WorkspaceMainPart method initialize.
@Override
public void initialize(final IManagedForm form) {
super.initialize(form);
final Composite container = (Composite) getSection().getClient();
// create a layout stack and the first visible component will be an empty component with "waiting" message
// this will be replaced by real composite once workspace completes
final StackLayout stackLayout = new StackLayout();
container.setLayout(stackLayout);
Composite labelParent = new Composite(container, SWT.NONE);
FillLayout fillLayout = new FillLayout();
fillLayout.marginHeight = fillLayout.marginWidth = 10;
labelParent.setLayout(fillLayout);
if (!Central.isWorkspaceInited()) {
Label label = new Label(labelParent, SWT.NONE);
label.setText("Workspace is loading, please wait...");
label.setBackground(container.getBackground());
label.setForeground(container.getForeground());
}
stackLayout.topControl = labelParent;
container.layout();
Central.onWorkspaceInit(new Success<Workspace, Void>() {
@Override
public Promise<Void> call(Promise<Workspace> resolved) throws Exception {
final Deferred<Void> completion = new Deferred<>();
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
try {
IFile buildFile = Central.getWorkspaceBuildFile();
if (buildFile == null)
return;
Composite contents = new Composite(container, SWT.NONE);
if (!mainFile) {
ImageHyperlink link = form.getToolkit().createImageHyperlink(contents, SWT.CENTER);
link.setText("Open main build.bnd file.");
link.setImage(bndFileImg);
link.addHyperlinkListener(new FileOpenLinkListener(buildFile.getFullPath()));
} else {
IResource[] extFiles;
IContainer cnfDir = buildFile.getParent();
IFolder extDir = cnfDir.getFolder(new Path("ext"));
if (extDir.exists())
extFiles = extDir.members();
else
extFiles = new IResource[0];
if (extFiles.length > 0) {
for (IResource extFile : extFiles) {
if (extFile.getType() == IResource.FILE && "bnd".equalsIgnoreCase(extFile.getFileExtension())) {
ImageHyperlink link = form.getToolkit().createImageHyperlink(contents, SWT.CENTER);
link.setText("Open " + extFile.getName());
link.setImage(extFileImg);
link.addHyperlinkListener(new FileOpenLinkListener(extFile.getFullPath()));
}
}
} else {
createMissingExtsWarningPanel(contents, form.getToolkit(), extDir.getFullPath());
}
}
stackLayout.topControl = contents;
container.layout();
completion.resolve(null);
} catch (Exception e) {
Plugin.error(Collections.singletonList(e.getMessage()));
completion.fail(e);
}
}
});
return completion.getPromise();
}
});
}
use of aQute.bnd.build.Workspace in project bndtools by bndtools.
the class JpmDependencyWizardPage method runQuery.
private void runQuery() {
if (!queried) {
errorText = null;
try {
Workspace workspace = Central.getWorkspace();
repository = workspace.getPlugin(SearchableRepository.class);
if (repository == null)
throw new Exception("No searchable repository is configured in the workspace. Try adding the JPM4J plugin.");
QueryJpmDependenciesRunnable query = new QueryJpmDependenciesRunnable(originUri, repository);
getContainer().run(true, true, query);
queried = true;
errorText = query.getError();
directResources = query.getDirectResources();
indirectResources = query.getIndirectResources();
selectedIndirectResources = new HashSet<ResourceDescriptor>();
} catch (InvocationTargetException e) {
errorText = e.getCause().getMessage();
} catch (InterruptedException e) {
// ignore
} catch (Exception e) {
errorText = e.getMessage();
} finally {
updateUi();
}
}
}
Aggregations