Java Code Examples for org.eclipse.core.resources.IncrementalProjectBuilder#FULL_BUILD

The following examples show how to use org.eclipse.core.resources.IncrementalProjectBuilder#FULL_BUILD . 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: CheckstyleBuilder.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Builds all checkstyle enabled projects that are open from the given collection of projects.
 *
 * @param projects
 *          the projects to build
 * @throws CheckstylePluginException
 *           Error during the build
 */
public static void buildProjects(final Collection<IProject> projects)
        throws CheckstylePluginException {

  // Build only open projects with Checkstyle enabled
  List<IProject> checkstyleProjects = new ArrayList<>();

  for (IProject project : projects) {

    try {
      if (project.exists() && project.isOpen() && project.hasNature(CheckstyleNature.NATURE_ID)) {
        checkstyleProjects.add(project);
      }
    } catch (CoreException e) {
      CheckstylePluginException.rethrow(e);
    }
  }

  // uses the new Jobs API to run the build in the background
  BuildProjectJob buildJob = new BuildProjectJob(
          checkstyleProjects.toArray(new IProject[checkstyleProjects.size()]),
          IncrementalProjectBuilder.FULL_BUILD);
  buildJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
  buildJob.schedule();
}
 
Example 2
Source File: CheckstyleBuilder.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Runs the Checkstyle builder on a project.
 *
 * @param project
 *          Project to be built.
 */
public static void buildProject(final IProject project) {
  // uses the new Jobs API to run the build in the background
  BuildProjectJob buildJob = new BuildProjectJob(project, IncrementalProjectBuilder.FULL_BUILD);
  buildJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
  buildJob.schedule();
}
 
Example 3
Source File: CheckstylePropertyPage.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public boolean performOk() {

  try {

    IProject project = mProjectConfig.getProject();

    // save the edited project configuration
    if (mProjectConfig.isDirty()) {
      mProjectConfig.store();
    }

    boolean checkstyleEnabled = mChkEnable.getSelection();
    boolean needRebuild = mProjectConfig.isRebuildNeeded();

    // check if checkstyle nature has to be configured/deconfigured
    if (checkstyleEnabled != mCheckstyleInitiallyActivated) {

      ConfigureDeconfigureNatureJob configOperation = new ConfigureDeconfigureNatureJob(project,
              CheckstyleNature.NATURE_ID);
      configOperation.setRule(ResourcesPlugin.getWorkspace().getRoot());
      configOperation.schedule();

      needRebuild = needRebuild || !mCheckstyleInitiallyActivated;
    }

    if (checkstyleEnabled && mProjectConfig.isSyncFormatter()) {

      TransformCheckstyleRulesJob transFormJob = new TransformCheckstyleRulesJob(project);
      transFormJob.schedule();
    }

    // if a rebuild is advised, check/prompt if the rebuild should
    // really be done.
    if (checkstyleEnabled && needRebuild) {

      String promptRebuildPref = CheckstyleUIPluginPrefs
              .getString(CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD);

      boolean doRebuild = MessageDialogWithToggle.ALWAYS.equals(promptRebuildPref) && needRebuild;

      //
      // Prompt for rebuild
      //
      if (MessageDialogWithToggle.PROMPT.equals(promptRebuildPref) && needRebuild) {
        MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getShell(),
                Messages.CheckstylePropertyPage_titleRebuild,
                Messages.CheckstylePropertyPage_msgRebuild,
                Messages.CheckstylePropertyPage_nagRebuild, false,
                CheckstyleUIPlugin.getDefault().getPreferenceStore(),
                CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD);

        doRebuild = dialog.getReturnCode() == IDialogConstants.YES_ID;
      }

      // check if a rebuild is necessary
      if (checkstyleEnabled && doRebuild) {

        BuildProjectJob rebuildOperation = new BuildProjectJob(project,
                IncrementalProjectBuilder.FULL_BUILD);
        rebuildOperation.setRule(ResourcesPlugin.getWorkspace().getRoot());
        rebuildOperation.schedule();
      }
    }
  } catch (CheckstylePluginException e) {
    CheckstyleUIPlugin.errorDialog(getShell(), e, true);
  }
  return true;
}
 
Example 4
Source File: RebuildProjectCommandHandler.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public RebuildProjectCommandHandler() {
    // TODO : supply correct progress monitor
    super(IncrementalProjectBuilder.FULL_BUILD);
}
 
Example 5
Source File: RebuildFileCommandHandler.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public RebuildFileCommandHandler() {
    super(IncrementalProjectBuilder.FULL_BUILD);
}
 
Example 6
Source File: CompileFileCommandHandler.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public CompileFileCommandHandler() {
    super(IncrementalProjectBuilder.FULL_BUILD);
}
 
Example 7
Source File: BuildProjectCommandHandler.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public BuildProjectCommandHandler() {
    super(IncrementalProjectBuilder.FULL_BUILD);
}
 
Example 8
Source File: FindBugsBuilder.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Run the builder.
 *
 * @see IncrementalProjectBuilder#build
 */
@SuppressWarnings("rawtypes")
@Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
    monitor.subTask("Running SpotBugs...");
    switch (kind) {
    case IncrementalProjectBuilder.FULL_BUILD: {
        FindBugs2Eclipse.cleanClassClache(getProject());
        if (FindbugsPlugin.getUserPreferences(getProject()).isRunAtFullBuild()) {
            if (DEBUG) {
                System.out.println("FULL BUILD");
            }
            doBuild(args, monitor, kind);
        } else {
            // TODO probably worth to cleanup?
            // MarkerUtil.removeMarkers(getProject());
        }
        break;
    }
    case IncrementalProjectBuilder.INCREMENTAL_BUILD: {
        if (DEBUG) {
            System.out.println("INCREMENTAL BUILD");
        }
        doBuild(args, monitor, kind);
        break;
    }
    case IncrementalProjectBuilder.AUTO_BUILD: {
        if (DEBUG) {
            System.out.println("AUTO BUILD");
        }
        doBuild(args, monitor, kind);
        break;
    }
    default: {

        FindbugsPlugin.getDefault()
                .logWarning("UKNOWN BUILD kind" + kind);
        doBuild(args, monitor, kind);
        break;
    }
    }
    return null;
}
 
Example 9
Source File: UnifiedBuilder.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException
{
	traceParticipantsEnabled = IdeLog.isTraceEnabled(BuildPathCorePlugin.getDefault(),
			IDebugScopes.BUILDER_PARTICIPANTS);

	boolean logTraceEnabled = traceLoggingEnabled();

	IProject project = getProjectHandle();
	String projectName = project.getName();
	long startTime = System.nanoTime();

	SubMonitor sub = SubMonitor.convert(monitor, 100);

	// Keep these build participant instances and use them in the build process, rather than grabbing new ones
	// in sub-methods. We do pre- and post- setups on them, so we need to retain instances.
	IBuildParticipantManager manager = getBuildParticipantManager();
	if (manager == null)
	{
		return new IProject[0];
	}
	List<IBuildParticipant> participants = manager.getAllBuildParticipants();
	participants = filterToEnabled(participants, project);
	buildStarting(participants, kind, sub.newChild(10));

	if (kind == IncrementalProjectBuilder.FULL_BUILD)
	{
		if (logTraceEnabled)
		{
			logTrace(MessageFormat.format(Messages.UnifiedBuilder_PerformingFullBuld, projectName));
		}
		fullBuild(participants, sub.newChild(80));
	}
	else
	{
		IResourceDelta delta = getResourceDelta();
		if (delta == null)
		{
			if (logTraceEnabled)
			{
				logTrace(MessageFormat.format(Messages.UnifiedBuilder_PerformingFullBuildNullDelta, projectName));
			}
			fullBuild(participants, sub.newChild(80));
		}
		else
		{
			if (logTraceEnabled)
			{
				logTrace(MessageFormat.format(Messages.UnifiedBuilder_PerformingIncrementalBuild, projectName));
			}
			incrementalBuild(participants, delta, sub.newChild(80));
		}
	}

	buildEnding(participants, sub.newChild(10));

	if (logTraceEnabled)
	{
		double endTime = ((double) System.nanoTime() - startTime) / 1000000;
		logTrace(MessageFormat.format(Messages.UnifiedBuilder_FinishedBuild, projectName, endTime));
	}
	return null;
}