use of aQute.bnd.build.Container in project bnd by bndtools.
the class BndrunResolveContext method loadPath.
/**
* Add a path to the system resource. This is done by the bnd launcher for
* -runpath and it is also used for -distro.
*/
public void loadPath(ResourceBuilder system, String path, String what) throws Exception {
if (project != null) {
List<Container> containers = Container.flatten(project.getBundles(Strategy.HIGHEST, path, what));
for (Container c : containers) {
Manifest manifest = c.getManifest();
if (manifest != null) {
ResourceBuilder rb = new ResourceBuilder();
rb.addManifest(Domain.domain(manifest));
addSystemResource(system, rb.build());
}
}
} else {
super.loadPath(system, path, what);
}
}
use of aQute.bnd.build.Container in project bndtools by bndtools.
the class BndDependencySourceContainer method createSourceContainers.
@Override
protected ISourceContainer[] createSourceContainers() throws CoreException {
List<ISourceContainer> result = new LinkedList<ISourceContainer>();
ILaunchConfiguration config = getLaunchConfiguration();
Set<String> projectsAdded = new HashSet<>();
try {
if (lastRun != null) {
LaunchUtils.endRun(lastRun);
}
Run run = LaunchUtils.createRun(config);
if (run != null) {
Collection<Container> runbundles = run.getRunbundles();
for (Container runbundle : runbundles) {
if (runbundle.getType() == TYPE.PROJECT) {
String targetProjName = runbundle.getProject().getName();
if (projectsAdded.add(targetProjName)) {
IProject targetProj = ResourcesPlugin.getWorkspace().getRoot().getProject(targetProjName);
if (targetProj != null) {
IJavaProject targetJavaProj = JavaCore.create(targetProj);
result.add(new JavaProjectSourceContainer(targetJavaProj));
}
}
} else if (runbundle.getType() == TYPE.REPO) {
IPath bundlePath = Central.toPath(runbundle.getFile());
IFile bundleFile = null;
if (bundlePath != null) {
bundleFile = ResourcesPlugin.getWorkspace().getRoot().getFile(bundlePath);
}
if (bundleFile != null) {
ISourceContainer sourceContainer = null;
// check to see if this archive came from a repo that encodes the source project name
final String sourceProjectName = runbundle.getAttributes().get("sourceProjectName");
if (sourceProjectName != null) {
try {
IProject sourceProject = ResourcesPlugin.getWorkspace().getRoot().getProject(sourceProjectName);
if (sourceProject.exists()) {
IJavaProject javaSourceProject = JavaCore.create(sourceProject);
sourceContainer = new JavaProjectSourceContainer(javaSourceProject);
}
} catch (Exception e) {
logger.logError("Error getting source java project", e);
}
}
if (sourceContainer == null) {
// default to archive source container
sourceContainer = new ArchiveSourceContainer(bundleFile, false);
}
result.add(sourceContainer);
} else {
ExternalArchiveSourceContainer container = new ExternalArchiveSourceContainer(runbundle.getFile().toString(), false);
result.add(container);
}
}
}
lastRun = run;
}
} catch (Exception e) {
logger.logError("Error querying Bnd dependency source containers.", e);
}
return result.toArray(new ISourceContainer[0]);
}
use of aQute.bnd.build.Container in project bndtools by bndtools.
the class BndContainerPage method createControl.
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets .Composite)
*/
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new FormLayout());
composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
composite.setFont(parent.getFont());
setControl(composite);
final Button wCreate = new Button(composite, SWT.NONE);
wCreate.setEnabled(model == null);
final FormData fd_wCreate = new FormData();
fd_wCreate.bottom = new FormAttachment(100, -5);
fd_wCreate.right = new FormAttachment(100, -4);
wCreate.setLayoutData(fd_wCreate);
wCreate.setText("Create bnd.bnd");
final TableViewer tableViewer = new TableViewer(composite, SWT.BORDER);
table = tableViewer.getTable();
final FormData fd_table = new FormData();
fd_table.top = new FormAttachment(0, 3);
fd_table.left = new FormAttachment(0, 3);
fd_table.right = new FormAttachment(100, -4);
fd_table.bottom = new FormAttachment(100, -37);
table.setLayoutData(fd_table);
table.setLinesVisible(true);
table.setHeaderVisible(true);
final TableColumn wBsn = new TableColumn(table, SWT.NONE);
wBsn.setWidth(200);
wBsn.setText("Bundle Symbolic Name");
final TableColumn wVersion = new TableColumn(table, SWT.NONE);
wVersion.setWidth(100);
wVersion.setText("Version");
final TableColumn wOptions = new TableColumn(table, SWT.NONE);
wOptions.setWidth(200);
wOptions.setText("Options");
final TableColumn wFile = new TableColumn(table, SWT.NONE);
wFile.setWidth(100);
wFile.setText("File");
tableViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
if (model != null)
try {
return model.getBuildpath().toArray();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new Object[0];
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
@Override
public Image getColumnImage(Object element, int columnIndex) {
// TODO Auto-generated method stub
return null;
}
@Override
public String getColumnText(Object element, int columnIndex) {
Container c = (Container) element;
switch(columnIndex) {
case 0:
return c.getBundleSymbolicName();
case 1:
return c.getVersion();
case 2:
return c.getError();
case 3:
return c.getFile() + " (" + (c.getFile() != null && c.getFile().exists() ? "exists" : "?") + ")";
default:
break;
}
return null;
}
@Override
public void addListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public boolean isLabelProperty(Object element, String property) {
// TODO Auto-generated method stub
return false;
}
@Override
public void removeListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
});
tableViewer.setInput(model);
wCreate.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
System.out.println("defw selected");
}
@Override
public void widgetSelected(SelectionEvent e) {
wCreate.setEnabled(!createBnd());
tableViewer.setInput(model);
}
});
}
use of aQute.bnd.build.Container in project bnd by bndtools.
the class ContainerTest method testBundleClasspath.
public void testBundleClasspath() throws Exception {
try (Builder b = new Builder()) {
b.addClasspath(new File("bin"));
b.setBundleClasspath(".,osgi.jar");
b.setIncludeResource("jar/osgi.jar");
b.setExportPackage("test.annotation");
b.setProperty("Hello", "World");
b.build();
assertTrue(b.check());
File testjar = IO.getFile(tmp, "test.jar");
b.getJar().write(testjar);
Attrs attrs = new Attrs();
attrs.put("expand-bcp", "true");
Container c = new Container(testjar, null, attrs);
List<File> files = new ArrayList<>();
c.contributeFiles(files, b);
assertEquals(2, files.size());
assertEquals(files.get(0).getCanonicalFile(), testjar.getCanonicalFile());
}
}
use of aQute.bnd.build.Container in project bnd by bndtools.
the class ProjectTest method testWildcardBuildPathWithRepoFilter.
public void testWildcardBuildPathWithRepoFilter() throws Exception {
Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
Project project = ws.getProject("repofilter");
assertNotNull(project);
project.setProperty("-buildpath", "*; repo=Relea*");
ArrayList<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
assertEquals(2, buildpath.size());
assertEquals(Container.TYPE.REPO, buildpath.get(0).getType());
assertEquals("org.apache.felix.configadmin", buildpath.get(0).getBundleSymbolicName());
assertEquals(Container.TYPE.REPO, buildpath.get(1).getType());
assertEquals("p3", buildpath.get(1).getBundleSymbolicName());
}
Aggregations