public ExitCode build()

in serverFacade/src/org/jetbrains/jps/incremental/java/JavaBuilder.java [82:128]


  public ExitCode build(final CompileContext context, final ModuleChunk chunk) throws ProjectBuildException {
    try {
      final TimestampStorage tsStorage = context.getBuildDataManager().getTimestampStorage(BUILDER_NAME);
      final Set<File> filesToCompile = new HashSet<File>();
      final List<File> formsToCompile = new ArrayList<File>();
      final Set<String> srcRoots = new HashSet<String>();

      context.processFiles(chunk, new FileProcessor() {
        public boolean apply(Module module, File file, String sourceRoot) throws Exception {
          if (JAVA_SOURCES_FILTER.accept(file)) {
            srcRoots.add(sourceRoot);
            if (isFileDirty(file, context, tsStorage)) {
              filesToCompile.add(file);
            }
          }
          else if (FORM_SOURCES_FILTER.accept(file)){
            if (isFileDirty(file, context, tsStorage)) {
              formsToCompile.add(file);
            }
          }
          return true;
        }
      });

      for (File form : formsToCompile) {
        for (String root : srcRoots) {
          final File boundSource = getBoundSource(root, form);
          if (boundSource != null) {
            // force compilation of classes that modified forms are bound to
            filesToCompile.add(boundSource);
            break;
          }
        }
      }

      return compile(context, chunk, filesToCompile, formsToCompile);
    }
    catch (Exception e) {
      String message = e.getMessage();
      if (message == null) {
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        e.printStackTrace(new PrintStream(out));
        message = "Internal error: \n" + out.toString();
      }
      throw new ProjectBuildException(message, e);
    }
  }