use of org.jetbrains.jps.model.java.JavaModuleIndex in project intellij-community by JetBrains.
the class JavaBuilder method doBuild.
public ExitCode doBuild(@NotNull CompileContext context, @NotNull ModuleChunk chunk, @NotNull DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, @NotNull OutputConsumer outputConsumer, @NotNull JavaCompilingTool compilingTool) throws ProjectBuildException, IOException {
try {
final Set<File> filesToCompile = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
dirtyFilesHolder.processDirtyFiles(new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
@Override
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor descriptor) throws IOException {
if (JAVA_SOURCES_FILTER.accept(file) && ourCompilableModuleTypes.contains(target.getModule().getModuleType())) {
filesToCompile.add(file);
}
return true;
}
});
if ((!filesToCompile.isEmpty() || dirtyFilesHolder.hasRemovedFiles()) && JpsJavaSdkType.parseVersion(getLanguageLevel(ContainerUtil.getFirstItem(chunk.getModules()))) >= 9) {
// at the moment, there is no incremental compilation for module-info files, so they should be rebuilt on every change
JavaModuleIndex index = getJavaModuleIndex(context);
for (JpsModule module : chunk.getModules()) {
ContainerUtil.addIfNotNull(filesToCompile, index.getModuleInfoFile(module));
}
}
if (JavaBuilderUtil.isCompileJavaIncrementally(context)) {
ProjectBuilderLogger logger = context.getLoggingManager().getProjectBuilderLogger();
if (logger.isEnabled() && !filesToCompile.isEmpty()) {
logger.logCompiledFiles(filesToCompile, BUILDER_NAME, "Compiling files:");
}
}
return compile(context, chunk, dirtyFilesHolder, filesToCompile, outputConsumer, compilingTool);
} catch (BuildDataCorruptedException | PersistentEnumeratorBase.CorruptedException | ProjectBuildException e) {
throw e;
} catch (Exception e) {
LOG.info(e);
String message = e.getMessage();
if (message == null) {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream stream = new PrintStream(out);
try {
e.printStackTrace(stream);
} finally {
stream.close();
}
message = "Internal error: \n" + out;
}
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, message));
throw new StopBuildException();
}
}
Aggregations