use of org.jetbrains.jps.builders.BuildRootIndex in project intellij-community by JetBrains.
the class ResourcesTarget method writeConfiguration.
@Override
public void writeConfiguration(ProjectDescriptor pd, PrintWriter out) {
int fingerprint = 0;
final BuildRootIndex rootIndex = pd.getBuildRootIndex();
final List<ResourceRootDescriptor> roots = rootIndex.getTargetRoots(this, null);
for (ResourceRootDescriptor root : roots) {
fingerprint += FileUtil.fileHashCode(root.getRootFile());
fingerprint += root.getPackagePrefix().hashCode();
}
out.write(Integer.toHexString(fingerprint));
}
use of org.jetbrains.jps.builders.BuildRootIndex in project intellij-community by JetBrains.
the class ChainedTargetsBuildListener method filesDeleted.
@Override
public void filesDeleted(FileDeletedEvent event) {
final BuildFSState state = myContext.getProjectDescriptor().fsState;
final BuildRootIndex rootsIndex = myContext.getProjectDescriptor().getBuildRootIndex();
for (String path : event.getFilePaths()) {
final File file = new File(FileUtil.toSystemDependentName(path));
for (BuildRootDescriptor desc : rootsIndex.findAllParentDescriptors(file, myContext)) {
state.registerDeleted(myContext, desc.getTarget(), file);
}
}
}
use of org.jetbrains.jps.builders.BuildRootIndex in project intellij-community by JetBrains.
the class CompilingGroovycRunner method addStubRootsToJavacSourcePath.
private static void addStubRootsToJavacSourcePath(CompileContext context, Map<ModuleBuildTarget, String> generationOutputs) {
final BuildRootIndex rootsIndex = context.getProjectDescriptor().getBuildRootIndex();
for (ModuleBuildTarget target : generationOutputs.keySet()) {
File root = new File(generationOutputs.get(target));
rootsIndex.associateTempRoot(context, target, new JavaSourceRootDescriptor(root, target, true, true, "", Collections.<File>emptySet()));
}
}
use of org.jetbrains.jps.builders.BuildRootIndex in project intellij-community by JetBrains.
the class JavaBuilder method compile.
private ExitCode compile(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, Collection<File> files, OutputConsumer outputConsumer, JavaCompilingTool compilingTool) throws Exception {
ExitCode exitCode = ExitCode.NOTHING_DONE;
final boolean hasSourcesToCompile = !files.isEmpty();
if (!hasSourcesToCompile && !dirtyFilesHolder.hasRemovedFiles()) {
return exitCode;
}
final ProjectDescriptor pd = context.getProjectDescriptor();
JavaBuilderUtil.ensureModuleHasJdk(chunk.representativeTarget().getModule(), context, BUILDER_NAME);
final Collection<File> classpath = ProjectPaths.getCompilationClasspath(chunk, false);
final Collection<File> platformCp = ProjectPaths.getPlatformCompilationClasspath(chunk, false);
// begin compilation round
final OutputFilesSink outputSink = new OutputFilesSink(context, outputConsumer, JavaBuilderUtil.getDependenciesRegistrar(context), chunk.getPresentableShortName());
Collection<File> filesWithErrors = null;
try {
if (hasSourcesToCompile) {
exitCode = ExitCode.OK;
final Set<File> srcPath = new HashSet<>();
final BuildRootIndex index = pd.getBuildRootIndex();
for (ModuleBuildTarget target : chunk.getTargets()) {
for (JavaSourceRootDescriptor rd : index.getTempTargetRoots(target, context)) {
srcPath.add(rd.root);
}
}
final DiagnosticSink diagnosticSink = new DiagnosticSink(context);
final String chunkName = chunk.getName();
context.processMessage(new ProgressMessage("Parsing java... [" + chunk.getPresentableShortName() + "]"));
final int filesCount = files.size();
boolean compiledOk = true;
if (filesCount > 0) {
LOG.info("Compiling " + filesCount + " java files; module: " + chunkName + (chunk.containsTests() ? " (tests)" : ""));
if (LOG.isDebugEnabled()) {
for (File file : files) {
LOG.debug("Compiling " + file.getPath());
}
LOG.debug(" classpath for " + chunkName + ":");
for (File file : classpath) {
LOG.debug(" " + file.getAbsolutePath());
}
LOG.debug(" platform classpath for " + chunkName + ":");
for (File file : platformCp) {
LOG.debug(" " + file.getAbsolutePath());
}
}
try {
compiledOk = compileJava(context, chunk, files, classpath, platformCp, srcPath, diagnosticSink, outputSink, compilingTool);
} finally {
// heuristic: incorrect paths data recovery, so that the next make should not contain non-existing sources in 'recompile' list
filesWithErrors = diagnosticSink.getFilesWithErrors();
for (File file : filesWithErrors) {
if (!file.exists()) {
FSOperations.markDeleted(context, file);
}
}
}
}
context.checkCanceled();
if (!compiledOk && diagnosticSink.getErrorCount() == 0) {
diagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, "Compilation failed: internal java compiler error"));
}
if (!Utils.PROCEED_ON_ERROR_KEY.get(context, Boolean.FALSE) && diagnosticSink.getErrorCount() > 0) {
if (!compiledOk) {
diagnosticSink.report(new JpsInfoDiagnostic("Errors occurred while compiling module '" + chunkName + "'"));
}
throw new StopBuildException("Compilation failed: errors: " + diagnosticSink.getErrorCount() + "; warnings: " + diagnosticSink.getWarningCount());
}
}
} finally {
JavaBuilderUtil.registerFilesToCompile(context, files);
if (filesWithErrors != null) {
JavaBuilderUtil.registerFilesWithErrors(context, filesWithErrors);
}
JavaBuilderUtil.registerSuccessfullyCompiled(context, outputSink.getSuccessfullyCompiled());
}
return exitCode;
}
use of org.jetbrains.jps.builders.BuildRootIndex in project intellij-community by JetBrains.
the class FSOperations method traverseRecursively.
private static void traverseRecursively(CompileContext context, final BuildRootDescriptor rd, final CompilationRound round, final File file, @NotNull final Timestamps tsStorage, final boolean forceDirty, @Nullable Set<File> currentFiles, @Nullable FileFilter filter, @NotNull FSCache fsCache) throws IOException {
BuildRootIndex rootIndex = context.getProjectDescriptor().getBuildRootIndex();
final File[] children = fsCache.getChildren(file);
if (children != null) {
// is directory
if (children.length > 0 && rootIndex.isDirectoryAccepted(file, rd)) {
for (File child : children) {
traverseRecursively(context, rd, round, child, tsStorage, forceDirty, currentFiles, filter, fsCache);
}
}
} else {
// is file
if (rootIndex.isFileAccepted(file, rd) && (filter == null || filter.accept(file))) {
boolean markDirty = forceDirty;
if (!markDirty) {
markDirty = tsStorage.getStamp(file, rd.getTarget()) != FileSystemUtil.lastModified(file);
}
if (markDirty) {
// if it is full project rebuild, all storages are already completely cleared;
// so passing null because there is no need to access the storage to clear non-existing data
final Timestamps marker = context.isProjectRebuild() ? null : tsStorage;
context.getProjectDescriptor().fsState.markDirty(context, round, file, rd, marker, false);
}
if (currentFiles != null) {
currentFiles.add(file);
}
}
}
}
Aggregations