use of org.jetbrains.jps.builders.java.dependencyView.Mappings in project intellij-community by JetBrains.
the class BuildDataManager method flush.
public void flush(boolean memoryCachesOnly) {
myTargetStoragesOwner.flush(memoryCachesOnly);
for (AtomicNotNullLazyValue<SourceToOutputMappingImpl> mapping : mySourceToOutputs.values()) {
mapping.getValue().flush(memoryCachesOnly);
}
myOutputToTargetRegistry.flush(memoryCachesOnly);
mySrcToFormMap.flush(memoryCachesOnly);
final Mappings mappings = myMappings;
if (mappings != null) {
synchronized (mappings) {
mappings.flush(memoryCachesOnly);
}
}
}
use of org.jetbrains.jps.builders.java.dependencyView.Mappings in project intellij-community by JetBrains.
the class StorageDumper method main.
public static void main(final String[] args) {
final Env env = new Env(args);
env.report();
final String dataPath = env.getProjectPath();
final String oath = env.getOutputPath();
if (dataPath == null) {
System.err.println("No project path specified.");
} else {
try {
final File parent = new File(oath == null ? "" : oath);
final File dataStorageRoot = new File(dataPath, "mappings");
final Mappings mappings = new Mappings(dataStorageRoot, true);
try {
//final File outputPath = new File(parent, "snapshot-" + new SimpleDateFormat("dd-MM-yy(hh-mm-ss)").format(new Date()) + ".log");
//FileUtil.createIfDoesntExist(outputPath);
//final PrintStream p = new PrintStream(outputPath);
//mappings.toStream(p);
//p.close();
mappings.toStream(parent);
} finally {
mappings.close();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
use of org.jetbrains.jps.builders.java.dependencyView.Mappings in project intellij-community by JetBrains.
the class JavaBuilderUtil method updateMappings.
/**
* @param filesToCompile files compiled in this round
* @param markDirtyRound compilation round at which dirty files should be visible to builders
* @return true if additional compilation pass is required, false otherwise
* @throws Exception
*/
private static boolean updateMappings(CompileContext context, final Mappings delta, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, ModuleChunk chunk, Collection<File> filesToCompile, Collection<File> successfullyCompiled, final CompilationRound markDirtyRound, @Nullable FileFilter skipMarkingDirtyFilter) throws IOException {
try {
boolean performIntegrate = true;
boolean additionalPassRequired = false;
final Set<String> removedPaths = getRemovedPaths(chunk, dirtyFilesHolder);
final Mappings globalMappings = context.getProjectDescriptor().dataManager.getMappings();
final boolean errorsDetected = Utils.errorsDetected(context);
if (!isForcedRecompilationAllJavaModules(context)) {
if (context.shouldDifferentiate(chunk)) {
context.processMessage(new ProgressMessage("Checking dependencies... [" + chunk.getPresentableShortName() + "]"));
final Set<File> allCompiledFiles = getFilesContainer(context, ALL_COMPILED_FILES_KEY);
final Set<File> allAffectedFiles = getFilesContainer(context, ALL_AFFECTED_FILES_KEY);
// mark as affected all files that were dirty before compilation
allAffectedFiles.addAll(filesToCompile);
// accumulate all successfully compiled in this round
allCompiledFiles.addAll(successfullyCompiled);
// unmark as affected all successfully compiled
allAffectedFiles.removeAll(successfullyCompiled);
final Set<File> affectedBeforeDif = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
affectedBeforeDif.addAll(allAffectedFiles);
final Set<File> compiledWithErrors = getFilesContainer(context, COMPILED_WITH_ERRORS_KEY);
COMPILED_WITH_ERRORS_KEY.set(context, null);
final ModulesBasedFileFilter moduleBasedFilter = new ModulesBasedFileFilter(context, chunk);
final boolean incremental = globalMappings.differentiateOnIncrementalMake(delta, removedPaths, filesToCompile, compiledWithErrors, allCompiledFiles, allAffectedFiles, moduleBasedFilter, CONSTANT_SEARCH_SERVICE.get(context));
if (LOG.isDebugEnabled()) {
LOG.debug("Differentiate Results:");
LOG.debug(" Compiled Files:");
for (final File c : allCompiledFiles) {
LOG.debug(" " + c.getAbsolutePath());
}
LOG.debug(" Affected Files:");
for (final File c : allAffectedFiles) {
LOG.debug(" " + c.getAbsolutePath());
}
LOG.debug("End Of Differentiate Results.");
}
if (incremental) {
final Set<File> newlyAffectedFiles = new HashSet<>(allAffectedFiles);
newlyAffectedFiles.removeAll(affectedBeforeDif);
final String infoMessage = "Dependency analysis found " + newlyAffectedFiles.size() + " affected files";
LOG.info(infoMessage);
context.processMessage(new ProgressMessage(infoMessage));
removeFilesAcceptedByFilter(newlyAffectedFiles, skipMarkingDirtyFilter);
if (!newlyAffectedFiles.isEmpty()) {
if (LOG.isDebugEnabled()) {
for (File file : newlyAffectedFiles) {
LOG.debug("affected file: " + file.getPath());
}
final List<Pair<File, JpsModule>> wrongFiles = checkAffectedFilesInCorrectModules(context, newlyAffectedFiles, moduleBasedFilter);
if (!wrongFiles.isEmpty()) {
LOG.debug("Wrong affected files for module chunk " + chunk.getName() + ": ");
for (Pair<File, JpsModule> pair : wrongFiles) {
final String name = pair.second != null ? pair.second.getName() : "null";
LOG.debug("\t[" + name + "] " + pair.first.getPath());
}
}
}
for (File file : newlyAffectedFiles) {
FSOperations.markDirtyIfNotDeleted(context, markDirtyRound, file);
}
additionalPassRequired = isCompileJavaIncrementally(context) && chunkContainsAffectedFiles(context, chunk, newlyAffectedFiles);
}
} else {
// non-incremental mode
final String messageText = "Marking " + chunk.getPresentableShortName() + " and direct dependants for recompilation";
LOG.info("Non-incremental mode: " + messageText);
context.processMessage(new ProgressMessage(messageText));
final boolean alreadyMarkedDirty = FSOperations.isMarkedDirty(context, chunk);
additionalPassRequired = isCompileJavaIncrementally(context) && !alreadyMarkedDirty;
if (alreadyMarkedDirty) {
// need this to make sure changes data stored in Delta is complete
globalMappings.differentiateOnNonIncrementalMake(delta, removedPaths, filesToCompile);
} else {
performIntegrate = false;
}
FileFilter toBeMarkedFilter = skipMarkingDirtyFilter == null ? null : new NegationFileFilter(skipMarkingDirtyFilter);
FSOperations.markDirtyRecursively(context, markDirtyRound, chunk, toBeMarkedFilter);
}
} else {
if (!errorsDetected) {
// makes sense only if we are going to integrate changes
globalMappings.differentiateOnNonIncrementalMake(delta, removedPaths, filesToCompile);
}
}
} else {
if (!errorsDetected) {
// makes sense only if we are going to integrate changes
globalMappings.differentiateOnRebuild(delta);
}
}
if (errorsDetected) {
// will be compiled during the first phase of the next make
return false;
}
if (performIntegrate) {
context.processMessage(new ProgressMessage("Updating dependency information... [" + chunk.getPresentableShortName() + "]"));
globalMappings.integrate(delta);
}
return additionalPassRequired;
} catch (BuildDataCorruptedException e) {
throw e.getCause();
} finally {
// clean progress messages
context.processMessage(new ProgressMessage(""));
}
}
use of org.jetbrains.jps.builders.java.dependencyView.Mappings in project intellij-community by JetBrains.
the class JavaBuilderUtil method getDependenciesRegistrar.
@NotNull
public static Callbacks.Backend getDependenciesRegistrar(CompileContext context) {
Pair<Mappings, Callbacks.Backend> pair = MAPPINGS_DELTA_KEY.get(context);
if (pair == null) {
final Mappings delta = context.getProjectDescriptor().dataManager.getMappings().createDelta();
pair = Pair.create(delta, delta.getCallback());
MAPPINGS_DELTA_KEY.set(context, pair);
}
return pair.second;
}
use of org.jetbrains.jps.builders.java.dependencyView.Mappings in project intellij-community by JetBrains.
the class JavaBuilderUtil method markDirtyDependenciesForInitialRound.
public static void markDirtyDependenciesForInitialRound(CompileContext context, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dfh, ModuleChunk chunk) throws IOException {
if (hasRemovedPaths(chunk, dfh)) {
final Mappings delta = context.getProjectDescriptor().dataManager.getMappings().createDelta();
final Set<File> empty = Collections.emptySet();
updateMappings(context, delta, dfh, chunk, empty, empty, CompilationRound.CURRENT, null);
}
}
Aggregations