org.eclipse.core.internal.events.BuildManager Java Examples
The following examples show how to use
org.eclipse.core.internal.events.BuildManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuildManagerAccess.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Enforce a build. */ public static void needBuild() { IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace instanceof Workspace) { BuildManager buildManager = ((Workspace) workspace).getBuildManager(); try { requestRebuild.invoke(buildManager); Object job = autoBuildJob.get(buildManager); forceBuild.invoke(job); } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(e); } } else { throw new RuntimeException("Unexpected workspace implementation"); } }
Example #2
Source File: BuildCancellationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void build(IBuildContext context, IProgressMonitor monitor) throws CoreException { super.build(context, monitor); if(isExternalInterrupt) { try { // simulate a workspace operation that interrupts the auto build like in // {@link Workspace#prepareOperation(org.eclipse.core.runtime.jobs.ISchedulingRule, IProgressMonitor)} BuildManager buildManager = ((Workspace) ResourcesPlugin.getWorkspace()).getBuildManager(); Field field0 = buildManager.getClass().getDeclaredField("autoBuildJob"); field0.setAccessible(true); Object autoBuildJob = field0.get(buildManager); Field field1 = autoBuildJob.getClass().getDeclaredField("interrupted"); field1.setAccessible(true); field1.set(autoBuildJob, true); isExternalInterrupt = false; } catch(Exception exc) { throw new RuntimeException(exc); } } if(cancelException != null) throw cancelException; }
Example #3
Source File: BuildManagerAccess.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Obtain the configured Xtext builder for the given project, if any. */ public static XtextBuilder findBuilder(IProject project) { try { if (project.isAccessible()) { Project casted = (Project) project; IBuildConfiguration activeBuildConfig = casted.getActiveBuildConfig(); for (ICommand command : casted.internalGetDescription().getBuildSpec(false)) { if (XtextBuilder.BUILDER_ID.equals(command.getBuilderName())) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace instanceof Workspace) { BuildManager buildManager = ((Workspace) workspace).getBuildManager(); XtextBuilder result = (XtextBuilder) getBuilder.invoke(buildManager, activeBuildConfig, command, -1, new MultiStatus(Activator.PLUGIN_ID, 0, null, null)); return result; } } } } return null; } catch (IllegalAccessException | InvocationTargetException | CoreException e) { throw new RuntimeException(e); } }
Example #4
Source File: BuildManagerAccess.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Enforce a build. */ public static void requestBuild() { IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace instanceof Workspace) { BuildManager buildManager = ((Workspace) workspace).getBuildManager(); try { requestRebuild.invoke(buildManager); Object job = autoBuildJob.get(buildManager); forceBuild.invoke(job); } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(e); } } else { throw new RuntimeException("Unexpected workspace implementation"); } }
Example #5
Source File: BuildUtil.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Synchronous run of a builder with the given name on the given project. * * @param project * @param kind * See {@link IncrementalProjectBuilder} for the available types. * @param builderName * @param args * @param monitor * @return A status indicating if the build succeeded or failed */ public static IStatus syncBuild(IProject project, int kind, String builderName, Map args, IProgressMonitor monitor) { try { IWorkspace workspace = ResourcesPlugin.getWorkspace(); BuildManager buildManager = ((Workspace) workspace).getBuildManager(); return buildManager.build(new BuildConfiguration(project), kind, builderName, args, monitor); } catch (IllegalStateException e) { return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, "Error while getting the Workspace", e); //$NON-NLS-1$ } }