Search in sources :

Example 71 with Project

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);
        }
    });
}
Also used : Project(aQute.bnd.build.Project) ProjectLibraryTable(com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) LanguageLevel(com.intellij.pom.java.LanguageLevel) IOException(java.io.IOException)

Example 72 with Project

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);
                }
            }
        }
    }
}
Also used : Project(aQute.bnd.build.Project) ProjectBuilder(aQute.bnd.build.ProjectBuilder) ProjectBuilder(aQute.bnd.build.ProjectBuilder) JarFile(java.util.jar.JarFile) File(java.io.File) Workspace(aQute.bnd.build.Workspace)

Example 73 with Project

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);
}
Also used : Project(aQute.bnd.build.Project)

Example 74 with Project

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;
}
Also used : Project(aQute.bnd.build.Project) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 75 with Project

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());
    }
}
Also used : RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) Project(aQute.bnd.build.Project) HyperlinkStyler(org.bndtools.utils.jface.HyperlinkStyler)

Aggregations

Project (aQute.bnd.build.Project)140 Workspace (aQute.bnd.build.Workspace)70 File (java.io.File)45 ArrayList (java.util.ArrayList)22 IProject (org.eclipse.core.resources.IProject)21 Container (aQute.bnd.build.Container)19 IOException (java.io.IOException)17 ProjectLauncher (aQute.bnd.build.ProjectLauncher)15 Version (aQute.bnd.version.Version)12 Description (aQute.lib.getopt.Description)12 Jar (aQute.bnd.osgi.Jar)11 Builder (aQute.bnd.osgi.Builder)10 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)10 IJavaProject (org.eclipse.jdt.core.IJavaProject)9 Run (aQute.bnd.build.Run)8 BuildException (org.apache.tools.ant.BuildException)8 CoreException (org.eclipse.core.runtime.CoreException)8 IFile (org.eclipse.core.resources.IFile)7 ProjectBuilder (aQute.bnd.build.ProjectBuilder)6 ProjectTester (aQute.bnd.build.ProjectTester)5