Search in sources :

Example 1 with IBuildConfiguration

use of org.eclipse.core.resources.IBuildConfiguration in project che by eclipse.

the class Project method getDescription.

@Override
public IProjectDescription getDescription() throws CoreException {
    return new IProjectDescription() {

        @Override
        public IBuildConfiguration[] getBuildConfigReferences(String s) {
            return new IBuildConfiguration[0];
        }

        @Override
        public ICommand[] getBuildSpec() {
            return new ICommand[0];
        }

        @Override
        public String getComment() {
            return null;
        }

        @Override
        public IProject[] getDynamicReferences() {
            return new IProject[0];
        }

        @Override
        public IPath getLocation() {
            return null;
        }

        @Override
        public URI getLocationURI() {
            return null;
        }

        @Override
        public String getName() {
            return null;
        }

        @Override
        public String[] getNatureIds() {
            RegisteredProject project = workspace.getProjectRegistry().getProject(path.toString());
            if (project == null) {
                ResourcesPlugin.log(new Status(IStatus.ERROR, "resource", "Can't find project: " + path.toOSString()));
                return new String[0];
            }
            Map<String, List<String>> attributes = project.getAttributes();
            String language = "";
            if (attributes.containsKey("language")) {
                language = attributes.get("language").get(0);
            }
            return "java".equals(language) ? new String[] { "org.eclipse.jdt.core.javanature" } : new String[] { language };
        }

        @Override
        public IProject[] getReferencedProjects() {
            return new IProject[0];
        }

        @Override
        public boolean hasNature(String s) {
            String[] natureIds = getNatureIds();
            for (String id : natureIds) {
                if (s.equals(id)) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public ICommand newCommand() {
            return null;
        }

        @Override
        public void setActiveBuildConfig(String s) {
        }

        @Override
        public void setBuildConfigs(String[] strings) {
        }

        @Override
        public void setBuildConfigReferences(String s, IBuildConfiguration[] iBuildConfigurations) {
        }

        @Override
        public void setBuildSpec(ICommand[] iCommands) {
        }

        @Override
        public void setComment(String s) {
        }

        @Override
        public void setDynamicReferences(IProject[] iProjects) {
        }

        @Override
        public void setLocation(IPath iPath) {
        }

        @Override
        public void setLocationURI(URI uri) {
        }

        @Override
        public void setName(String s) {
        }

        @Override
        public void setNatureIds(String[] strings) {
        }

        @Override
        public void setReferencedProjects(IProject[] iProjects) {
        }
    };
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) ICommand(org.eclipse.core.resources.ICommand) IProjectDescription(org.eclipse.core.resources.IProjectDescription) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) List(java.util.List) URI(java.net.URI) IProject(org.eclipse.core.resources.IProject) IBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration)

Example 2 with IBuildConfiguration

use of org.eclipse.core.resources.IBuildConfiguration in project n4js by eclipse.

the class RebuildWorkspaceProjectsScheduler method scheduleBuildIfNecessary.

/**
 * Schedules a build with the given projects. Does nothing if the {@link Platform platform} is not running, or the
 * iterable of projects is empty.
 *
 * @param toUpdate
 *            an iterable of projects to build.
 */
public void scheduleBuildIfNecessary(final Iterable<IProject> toUpdate) {
    if (Platform.isRunning() && !Iterables.isEmpty(toUpdate)) {
        final Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace();
        final IBuildConfiguration[] projectsToReBuild = from(asList(workspace.getBuildOrder())).filter(config -> Iterables.contains(toUpdate, config.getProject())).toArray(IBuildConfiguration.class);
        if (!Arrays2.isEmpty(projectsToReBuild)) {
            new RebuildWorkspaceProjectsJob(projectsToReBuild).schedule();
        }
    }
}
Also used : Workspace(org.eclipse.core.internal.resources.Workspace) Iterables(com.google.common.collect.Iterables) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) IProject(org.eclipse.core.resources.IProject) Arrays.asList(java.util.Arrays.asList) FluentIterable.from(com.google.common.collect.FluentIterable.from) IBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration) Platform(org.eclipse.core.runtime.Platform) Arrays2(org.eclipse.n4js.utils.collections.Arrays2) Workspace(org.eclipse.core.internal.resources.Workspace) IBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration)

Example 3 with IBuildConfiguration

use of org.eclipse.core.resources.IBuildConfiguration in project ow by vtst.

the class ClosureBuilder method buildAll.

/**
 * Force a build of all JavaScript projects in the workspace.
 */
public static void buildAll() {
    // Get the list of projects having the Closure nature
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    final ArrayList<IBuildConfiguration> configs = new ArrayList<IBuildConfiguration>(projects.length);
    for (IProject project : projects) {
        try {
            if (project.hasNature(ClosureNature.NATURE_ID)) {
                configs.add(project.getActiveBuildConfig());
            }
        } catch (CoreException e) {
        // This happens if the project is not open
        }
    }
    // Build
    Job buildAll = new Job(OwJsClosurePlugin.getDefault().getMessages().getString("build_all")) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                ResourcesPlugin.getWorkspace().build(configs.toArray(new IBuildConfiguration[0]), IncrementalProjectBuilder.FULL_BUILD, false, monitor);
                return Status.OK_STATUS;
            } catch (CoreException e) {
                return e.getStatus();
            }
        }
    };
    buildAll.schedule();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) Job(org.eclipse.core.runtime.jobs.Job) IProject(org.eclipse.core.resources.IProject) IBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration)

Example 4 with IBuildConfiguration

use of org.eclipse.core.resources.IBuildConfiguration in project linuxtools by eclipse.

the class CProjectBuildHelpers method rebuildProject.

/**
 * <h1>Trigger a re-build of the project.</h1>
 *
 * <p> Given a project, it finds the active configuration and rebuilds the project. </p>
 *
 * <p> This works with C/C++ Managed Builds as well as Autotools.</p>
 *
 * <p>Most useful for when you have added a flag to a project programmatically and want to rebuild
 * the project so that the program is rebuild with that flag. The Rebuild triggers an update of the makefile
 * automatically.</p>
 *
 * @param project to rebuild
 */
public static void rebuildProject(IProject project) {
    // rebuild does not generate an analysis file (e.g gmon.out) But since -pg flag is added, profiling support is added to the binary.
    try {
        IBuildConfiguration buildConfiguration = project.getActiveBuildConfig();
        // force a full rebuild which is usually needed for when you add profiling flags to the build options.
        project.build(buildConfiguration, IncrementalProjectBuilder.FULL_BUILD, null);
    } catch (CoreException e) {
        // This is a very rare occurrence. Usually rebuilds don't fail if they worked the first time.
        MessageDialogSyncedRunnable.openErrorSyncedRunnable(ProfilingMessages.errorTitle, ProfilingMessages.errorRebuilding);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration)

Aggregations

IBuildConfiguration (org.eclipse.core.resources.IBuildConfiguration)4 IProject (org.eclipse.core.resources.IProject)3 CoreException (org.eclipse.core.runtime.CoreException)2 FluentIterable.from (com.google.common.collect.FluentIterable.from)1 Iterables (com.google.common.collect.Iterables)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 RegisteredProject (org.eclipse.che.api.project.server.RegisteredProject)1 Workspace (org.eclipse.core.internal.resources.Workspace)1 ICommand (org.eclipse.core.resources.ICommand)1 IProjectDescription (org.eclipse.core.resources.IProjectDescription)1 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Platform (org.eclipse.core.runtime.Platform)1 Status (org.eclipse.core.runtime.Status)1 Job (org.eclipse.core.runtime.jobs.Job)1