mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[jps build] logging: show differences between dependencies configuration if debug logging is enabled
Before we print dependencies configuration text to the log for each build, it greatly increased log size after ordinary incremental builds. Also it wasn't easy to find previous configuration in log files and sometimes the corresponding entry was already removed from log files due to log rotation because building a big project with debug logging produces a lot of logs. Now we store full dependencies configuration to a separate file and report differences from previously stored data. GitOrigin-RevId: df4f06b9c52576764584debf0891a114d2b0f185
This commit is contained in:
committed by
intellij-monorepo-bot
parent
dd3f8fc6a9
commit
15f9c9813b
@@ -6,6 +6,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.FileCollectionFactory;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
@@ -35,6 +36,7 @@ import org.jetbrains.jps.service.JpsServiceManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -178,7 +180,7 @@ public final class ModuleBuildTarget extends JVMModuleBuildTarget<JavaSourceRoot
|
||||
final JpsModule module = getModule();
|
||||
final PathRelativizerService relativizer = pd.dataManager.getRelativizer();
|
||||
|
||||
final StringBuilder logBuilder = LOG.isTraceEnabled() ? new StringBuilder() : null;
|
||||
final StringBuilder logBuilder = LOG.isDebugEnabled() ? new StringBuilder() : null;
|
||||
|
||||
int fingerprint = getDependenciesFingerprint(logBuilder, relativizer);
|
||||
|
||||
@@ -220,7 +222,27 @@ public final class ModuleBuildTarget extends JVMModuleBuildTarget<JavaSourceRoot
|
||||
final String hash = Integer.toHexString(fingerprint);
|
||||
out.write(hash);
|
||||
if (logBuilder != null) {
|
||||
LOG.trace("Configuration hash for " + getPresentableName() + ": " + hash + "\n" + logBuilder);
|
||||
File configurationTextFile = new File(pd.getTargetsState().getDataPaths().getTargetDataRoot(this), "config.dat.debug.txt");
|
||||
@NonNls String oldText;
|
||||
try {
|
||||
oldText = FileUtil.loadFile(configurationTextFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
oldText = null;
|
||||
}
|
||||
String newText = logBuilder.toString();
|
||||
if (!newText.equals(oldText)) {
|
||||
if (oldText != null) {
|
||||
LOG.debug("Configuration differs from the last recorded one for " + getPresentableName() + ".\nRecorded configuration:\n" + oldText +
|
||||
"\nCurrent configuration (hash=" + hash + "):\n" + newText);
|
||||
}
|
||||
try {
|
||||
FileUtil.writeToFile(configurationTextFile, newText);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user