use of aQute.bnd.build.Project in project bnd by bndtools.
the class MavenTest method getProject.
/**
* @throws Exception
*/
protected static Project getProject(String name) throws Exception {
File wsf = IO.getFile(cwd, "testresources/ws");
Workspace ws = Workspace.getWorkspace(wsf);
assertNotNull(ws);
Project project = ws.getProject(name);
assertNotNull(project);
return project;
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class ProjectLaunchImplTest method testCwdIsProjectBase.
public void testCwdIsProjectBase() throws Exception {
Project project = ws.getProject("p1");
project.prepare();
ProjectLauncherImpl projectLauncherImpl = new ProjectLauncherImpl(project);
assertEquals(project.getBase(), projectLauncherImpl.getCwd());
projectLauncherImpl.close();
}
use of aQute.bnd.build.Project in project intellij-plugins by JetBrains.
the class BndProjectImportBuilder method commit.
@NotNull
@Override
public List<Module> commit(com.intellij.openapi.project.Project project, ModifiableModuleModel model, ModulesProvider modulesProvider, ModifiableArtifactModel artifactModel) {
if (model == null) {
model = ModuleManager.getInstance(project).getModifiableModel();
try {
List<Module> result = commit(project, model, modulesProvider, artifactModel);
WriteAction.run(model::commit);
return result;
} catch (RuntimeException | Error e) {
model.dispose();
throw e;
}
}
if (myWorkspace != null) {
List<Project> toImport = ContainerUtil.filter(myProjects, project1 -> isMarked(project1));
final BndProjectImporter importer = new BndProjectImporter(project, myWorkspace, toImport);
Module rootModule = importer.createRootModule(model);
importer.setupProject();
StartupManager.getInstance(project).registerPostStartupActivity(() -> importer.resolve(false));
return Collections.singletonList(rootModule);
} else {
File file = new File(getFileToImport());
if (BndProjectImporter.BND_FILE.equals(file.getName())) {
file = file.getParentFile();
}
BndProjectImporter.reimportProjects(project, Collections.singleton(file.getPath()));
return Collections.emptyList();
}
}
use of aQute.bnd.build.Project in project intellij-plugins by JetBrains.
the class BndProjectImporter method addEntry.
private void addEntry(ModifiableModuleModel moduleModel, LibraryTable.ModifiableModel libraryModel, ModifiableRootModel rootModel, Container dependency, DependencyScope scope) throws IllegalArgumentException {
File file = dependency.getFile();
String bsn = dependency.getBundleSymbolicName();
String version = dependency.getVersion();
String path = file.getPath();
if (path.contains(": ")) {
throw new IllegalArgumentException("Cannot resolve " + bsn + ":" + version + ": " + path);
}
if (JDK_DEPENDENCY.equals(bsn)) {
String name = BND_LIB_PREFIX + bsn + ":" + version;
if (FileUtil.isAncestor(myWorkspace.getBase(), file, true)) {
name += "-" + myProject.getName();
}
ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
Sdk jdk = jdkTable.findJdk(name);
if (jdk == null) {
jdk = jdkTable.createSdk(name, JavaSdk.getInstance());
SdkModificator jdkModel = jdk.getSdkModificator();
jdkModel.setHomePath(file.getParent());
jdkModel.setVersionString(version);
VirtualFile root = VirtualFileManager.getInstance().findFileByUrl(url(file));
assert root != null : file + " " + file.exists();
jdkModel.addRoot(root, OrderRootType.CLASSES);
VirtualFile srcRoot = VirtualFileManager.getInstance().findFileByUrl(url(file) + SRC_ROOT);
if (srcRoot != null)
jdkModel.addRoot(srcRoot, OrderRootType.SOURCES);
jdkModel.commitChanges();
jdkTable.addJdk(jdk);
}
rootModel.setSdk(jdk);
return;
}
ExportableOrderEntry entry;
switch(dependency.getType()) {
case PROJECT:
{
String name = dependency.getProject().getName();
Module module = moduleModel.findModuleByName(name);
if (module == null) {
throw new IllegalArgumentException("Unknown module '" + name + "'");
}
entry = (ModuleOrderEntry) ContainerUtil.find(rootModel.getOrderEntries(), e -> e instanceof ModuleOrderEntry && ((ModuleOrderEntry) e).getModule() == module);
if (entry == null) {
entry = rootModel.addModuleOrderEntry(module);
}
break;
}
case REPO:
{
String name = BND_LIB_PREFIX + bsn + ":" + version;
Library library = libraryModel.getLibraryByName(name);
if (library == null) {
library = libraryModel.createLibrary(name);
}
Library.ModifiableModel model = library.getModifiableModel();
for (String url : model.getUrls(OrderRootType.CLASSES)) model.removeRoot(url, OrderRootType.CLASSES);
for (String url : model.getUrls(OrderRootType.SOURCES)) model.removeRoot(url, OrderRootType.SOURCES);
model.addRoot(url(file), OrderRootType.CLASSES);
String srcRoot = mySourcesMap.get(path);
if (srcRoot != null) {
model.addRoot(url(file) + srcRoot, OrderRootType.SOURCES);
}
model.commit();
entry = rootModel.addLibraryEntry(library);
break;
}
case EXTERNAL:
{
Library library = rootModel.getModuleLibraryTable().createLibrary(file.getName());
Library.ModifiableModel model = library.getModifiableModel();
model.addRoot(url(file), OrderRootType.CLASSES);
String srcRoot = mySourcesMap.get(path);
if (srcRoot != null) {
model.addRoot(url(file) + srcRoot, OrderRootType.SOURCES);
}
model.commit();
entry = rootModel.findLibraryOrderEntry(library);
assert entry != null : library;
break;
}
default:
throw new IllegalArgumentException("Unknown dependency '" + dependency + "' of type " + dependency.getType());
}
entry.setScope(scope);
}
use of aQute.bnd.build.Project in project intellij-plugins by JetBrains.
the class BndProjectImporter method resolve.
private boolean resolve(@Nullable ProgressIndicator indicator) {
int progress = 0;
for (Project project : myProjects) {
LOG.info("resolving: " + project.getBase());
if (indicator != null) {
indicator.checkCanceled();
indicator.setText(project.getName());
}
try {
project.prepare();
} catch (Exception e) {
checkErrors(project, e);
return false;
}
checkWarnings(project, project.getErrors(), true);
checkWarnings(project, project.getWarnings(), false);
findSources(project);
if (indicator != null) {
indicator.setFraction((double) (++progress) / myProjects.size());
}
}
return true;
}
Aggregations