use of aQute.bnd.build.Project in project intellij-plugins by JetBrains.
the class BndProjectImporter method createProjectStructure.
private void createProjectStructure() {
if (myProject.isDisposed()) {
return;
}
ApplicationManager.getApplication().runWriteAction(() -> {
LanguageLevel projectLevel = LanguageLevelProjectExtension.getInstance(myProject).getLanguageLevel();
Map<Project, ModifiableRootModel> rootModels = ContainerUtil.newHashMap();
ModifiableModuleModel moduleModel = ModuleManager.getInstance(myProject).getModifiableModel();
LibraryTable.ModifiableModel libraryModel = ProjectLibraryTable.getInstance(myProject).getModifiableModel();
try {
for (Project project : myProjects) {
try {
rootModels.put(project, createModule(moduleModel, project, projectLevel));
} catch (Exception e) {
// should not happen, since project.prepare() is already called
LOG.error(e);
}
}
for (Project project : myProjects) {
try {
setDependencies(moduleModel, libraryModel, rootModels.get(project), project);
} catch (Exception e) {
// should not happen, since project.prepare() is already called
LOG.error(e);
}
}
} finally {
libraryModel.commit();
ModifiableModelCommitter.multiCommit(rootModels.values(), moduleModel);
}
});
}
use of aQute.bnd.build.Project in project intellij-plugins by JetBrains.
the class BndWrapper method build.
/**
* Builds the .jar file for the given module.
*/
public void build(@NotNull File bndFile, @NotNull File[] classPath, @NotNull File[] srcPath, @NotNull File outputFile) throws Exception {
Workspace workspace = Workspace.findWorkspace(bndFile);
if (workspace != null) {
try (Project project = new Project(workspace, null, bndFile);
ProjectBuilder projectBuilder = project.getBuilder(null)) {
for (Builder sub : projectBuilder.getSubBuilders()) {
File source = sub == projectBuilder ? bndFile : sub.getPropertiesFile();
String prevSource = myReporter.setReportSource(source.getPath());
try (Builder builder = new ReportingProjectBuilder(myReporter, (ProjectBuilder) sub)) {
builder.setProperties(source);
File output = sub == projectBuilder ? outputFile : new File(outputFile.getParent(), sub.getBsn() + ".jar");
doBuild(builder, output);
} finally {
myReporter.setReportSource(prevSource);
}
}
}
} else {
try (Builder mainBuilder = new Builder()) {
mainBuilder.setProperties(bndFile);
mainBuilder.setPedantic(false);
for (Builder sub : mainBuilder.getSubBuilders()) {
File source = sub == mainBuilder ? bndFile : sub.getPropertiesFile();
String prevSource = myReporter.setReportSource(source.getPath());
try (Builder builder = new ReportingBuilder(myReporter, sub)) {
builder.setProperties(source);
builder.setPedantic(false);
builder.setClasspath(classPath);
builder.setSourcepath(srcPath);
File output = sub == mainBuilder ? outputFile : new File(outputFile.getParent(), sub.getBsn() + ".jar");
doBuild(builder, output);
} finally {
myReporter.setReportSource(prevSource);
}
}
}
}
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class ProjectLaunchImplTest method testParseSystemCapabilities.
public void testParseSystemCapabilities() throws Exception {
Project project = ws.getProject("p1");
project.prepare();
String systemCaps = null;
try {
ProjectLauncherImpl launcher = new ProjectLauncherImpl(project);
launcher.prepare();
systemCaps = launcher.getSystemCapabilities();
launcher.close();
} finally {
project.close();
ws.close();
}
assertEquals("osgi.native;osgi.native.osname:List<String>=\"Win7,Windows7,Windows 7\";osgi.native.osversion:Version=\"6.1\"", systemCaps);
}
use of aQute.bnd.build.Project in project bndtools by bndtools.
the class RepositoryTreeContentProvider method getChildren.
@Override
public Object[] getChildren(Object parentElement) {
Object[] result = null;
if (parentElement instanceof RepositoryPlugin) {
RepositoryPlugin repo = (RepositoryPlugin) parentElement;
result = getRepositoryBundles(repo);
} else if (parentElement instanceof RepositoryBundle) {
RepositoryBundle bundle = (RepositoryBundle) parentElement;
result = getRepositoryBundleVersions(bundle);
} else if (parentElement instanceof Project) {
Project project = (Project) parentElement;
result = getProjectBundles(project);
}
return result;
}
use of aQute.bnd.build.Project in project bndtools by bndtools.
the class RepositoryTreeLabelProvider method update.
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
int index = cell.getColumnIndex();
if (element instanceof RepositoryPlugin) {
if (index == 0) {
RepositoryPlugin repo = (RepositoryPlugin) element;
cell.setText(repo.getName());
Image image;
if (RepoUtils.isWorkspaceRepo(repo))
image = projectImg;
else if (isRemoteRepo((RepositoryPlugin) element))
image = remoteRepoImg;
else
image = localRepoImg;
cell.setImage(image);
}
} else if (element instanceof Project) {
if (index == 0) {
@SuppressWarnings("resource") Project project = (Project) element;
StyledString label = new StyledString(project.getName());
if (showRepoId)
label.append(" [Workspace]", StyledString.QUALIFIER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(projectImg);
}
} else if (element instanceof ProjectBundle) {
if (index == 0) {
StyledString label = new StyledString(((ProjectBundle) element).getBsn());
if (showRepoId)
label.append(" [Workspace]", StyledString.QUALIFIER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(bundleImg);
}
} else if (element instanceof RepositoryBundle) {
if (index == 0) {
RepositoryBundle bundle = (RepositoryBundle) element;
StyledString label = new StyledString(bundle.getText());
if (showRepoId)
label.append(" [" + bundle.getRepo().getName() + "]", StyledString.QUALIFIER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(bundleImg);
}
} else if (element instanceof RepositoryBundleVersion) {
if (index == 0) {
RepositoryBundleVersion bundleVersion = (RepositoryBundleVersion) element;
String versionText = bundleVersion.getText();
if (versionText.contains(" ⇩")) {
versionText = versionText.replaceAll(" ⇩", "");
cell.setImage(arrowImg);
}
StyledString styledString = new StyledString(versionText, StyledString.COUNTER_STYLER);
cell.setText(styledString.getString());
cell.setStyleRanges(styledString.getStyleRanges());
}
} else if (element instanceof RepositoryResourceElement) {
RepositoryResourceElement resourceElem = (RepositoryResourceElement) element;
StyledString label = new StyledString();
label.append(resourceElem.getIdentity()).append(" ");
label.append(resourceElem.getVersionString(), StyledString.COUNTER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(matchImg);
} else if (element instanceof ContinueSearchElement) {
StyledString label = new StyledString("Continue Search on JPM4J.org...", new HyperlinkStyler());
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
} else if (element instanceof LoadingContentElement) {
cell.setText("Loading content...");
cell.setImage(loadingImg);
} else if (element != null) {
// Catch-all
cell.setText(element.toString());
}
}
Aggregations