CustomPaths () { String isEnabled = System.getenv("JBC_SEPARATE_CONFIG"); if ("false".equalsIgnoreCase(isEnabled)) { return null; } Path oldConfigPath = PathManager.getConfigDir(); if (isConfigImportNeeded(oldConfigPath)) { customTargetDirectoryToImportConfig = oldConfigPath; } Path newConfig; Path tempFolder = Paths.get(PathManager.getTempPath()); int directoryCounter = 0; while (true) { newConfig = tempFolder.resolve("per_process_config_" + directoryCounter); FileLock configLock = tryLockDirectory(newConfig); if (configLock != null) { ourConfigLock = configLock; break; } if (directoryCounter > 1000) { System.err.println("Can't lock temp directories in " + tempFolder); return null; } directoryCounter++; } Path newSystem = tempFolder.resolve("per_process_system_" + directoryCounter); Path baseLogDir = PathManager.getLogDir(); Path newLog = computeLogDirPath(baseLogDir, directoryCounter); if (newLog == null) { System.err.println("Can't create log directory in " + baseLogDir); return null; } cleanDirectory(newConfig); cleanDirectory(newSystem); try { CustomConfigFiles.prepareConfigDir(newConfig, oldConfigPath); } catch (IOException e) { System.err.println("Failed to prepare config directory " + newConfig); //noinspection CallToPrintStackTrace e.printStackTrace(); } Path startupScriptDir = PathManager.getSystemDir().resolve("startup-script"); enabled = true; return new CustomPaths(newConfig.toString(), newSystem.toString(), PathManager.getPluginsPath(), newLog.toString(), startupScriptDir); }