Esempio n. 1
0
  protected void clean(IProgressMonitor monitor) throws CoreException {
    this.currentProject = getProject();
    if (this.currentProject == null || !this.currentProject.isAccessible()) return;

    if (DEBUG)
      System.out.println(
          "\nJavaBuilder: Cleaning "
              + this.currentProject.getName() // $NON-NLS-1$
              + " @ "
              + new Date(System.currentTimeMillis())); // $NON-NLS-1$
    this.notifier = new BuildNotifier(monitor, this.currentProject);
    this.notifier.begin();
    try {
      this.notifier.checkCancel();

      initializeBuilder(CLEAN_BUILD, true);
      if (DEBUG)
        System.out.println(
            "JavaBuilder: Clearing last state as part of clean : " + this.lastState); // $NON-NLS-1$
      clearLastState();
      removeProblemsAndTasksFor(this.currentProject);
      new BatchImageBuilder(this, false).cleanOutputFolders(false);
    } catch (CoreException e) {
      Util.log(
          e,
          "JavaBuilder handling CoreException while cleaning: "
              + this.currentProject.getName()); // $NON-NLS-1$
      createInconsistentBuildMarker(e);
    } finally {
      this.notifier.done();
      cleanup();
    }
    if (DEBUG)
      System.out.println(
          "JavaBuilder: Finished cleaning "
              + this.currentProject.getName() // $NON-NLS-1$
              + " @ "
              + new Date(System.currentTimeMillis())); // $NON-NLS-1$
  }
Esempio n. 2
0
  protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) throws CoreException {
    this.currentProject = getProject();
    if (this.currentProject == null || !this.currentProject.isAccessible()) return new IProject[0];

    if (DEBUG)
      System.out.println(
          "\nJavaBuilder: Starting build of "
              + this.currentProject.getName() // $NON-NLS-1$
              + " @ "
              + new Date(System.currentTimeMillis())); // $NON-NLS-1$
    this.notifier = new BuildNotifier(monitor, this.currentProject);
    this.notifier.begin();
    boolean ok = false;
    try {
      this.notifier.checkCancel();
      kind = initializeBuilder(kind, true);

      if (isWorthBuilding()) {
        if (kind == FULL_BUILD) {
          if (DEBUG)
            System.out.println("JavaBuilder: Performing full build as requested"); // $NON-NLS-1$
          buildAll();
        } else {
          if ((this.lastState = getLastState(this.currentProject)) == null) {
            if (DEBUG)
              System.out.println(
                  "JavaBuilder: Performing full build since last saved state was not found"); //$NON-NLS-1$
            buildAll();
          } else if (hasClasspathChanged()) {
            // if the output location changes, do not delete the binary files from old location
            // the user may be trying something
            if (DEBUG)
              System.out.println(
                  "JavaBuilder: Performing full build since classpath has changed"); //$NON-NLS-1$
            buildAll();
          } else if (this.nameEnvironment.sourceLocations.length > 0) {
            // if there is no source to compile & no classpath changes then we are done
            SimpleLookupTable deltas = findDeltas();
            if (deltas == null) {
              if (DEBUG)
                System.out.println(
                    "JavaBuilder: Performing full build since deltas are missing after incremental request"); //$NON-NLS-1$
              buildAll();
            } else if (deltas.elementSize > 0) {
              buildDeltas(deltas);
            } else if (DEBUG) {
              System.out.println(
                  "JavaBuilder: Nothing to build since deltas were empty"); //$NON-NLS-1$
            }
          } else {
            if (hasStructuralDelta()) { // double check that a jar file didn't get replaced in a
              // binary project
              if (DEBUG)
                System.out.println(
                    "JavaBuilder: Performing full build since there are structural deltas"); //$NON-NLS-1$
              buildAll();
            } else {
              if (DEBUG)
                System.out.println(
                    "JavaBuilder: Nothing to build since there are no source folders and no deltas"); //$NON-NLS-1$
              this.lastState.tagAsNoopBuild();
            }
          }
        }
        ok = true;
      }
    } catch (CoreException e) {
      Util.log(
          e,
          "JavaBuilder handling CoreException while building: "
              + this.currentProject.getName()); // $NON-NLS-1$
      createInconsistentBuildMarker(e);
    } catch (ImageBuilderInternalException e) {
      Util.log(
          e.getThrowable(),
          "JavaBuilder handling ImageBuilderInternalException while building: "
              + this.currentProject.getName()); // $NON-NLS-1$
      createInconsistentBuildMarker(e.coreException);
    } catch (MissingSourceFileException e) {
      // do not log this exception since its thrown to handle aborted compiles because of missing
      // source files
      if (DEBUG)
        System.out.println(Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile));
      removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project
      IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
      marker.setAttributes(
          new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IMarker.SOURCE_ID},
          new Object[] {
            Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile),
            new Integer(IMarker.SEVERITY_ERROR),
            JavaBuilder.SOURCE_ID
          });
    } finally {
      for (int i = 0, l = this.participants == null ? 0 : this.participants.length; i < l; i++)
        this.participants[i].buildFinished(this.javaProject);
      if (!ok)
        // If the build failed, clear the previously built state, forcing a full build next time.
        clearLastState();
      this.notifier.done();
      cleanup();
    }
    IProject[] requiredProjects = getRequiredProjects(true);
    if (DEBUG)
      System.out.println(
          "JavaBuilder: Finished build of "
              + this.currentProject.getName() // $NON-NLS-1$
              + " @ "
              + new Date(System.currentTimeMillis())
              + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
    return requiredProjects;
  }