private static File createFolderAndSystemProperty(String property, File defaultFolder) { File folder; String folderPath = getSystemOrEnvironmentProperty(property); if (folderPath == null || folderPath.isEmpty()) { folder = defaultFolder; } else { folder = new File(folderPath); } folder.mkdirs(); System.setProperty(property, folder.getPath()); return folder; }
File droidWorkDir = createFolderAndSystemProperty(DROID_USER, defaultDroidWorkingFolder); File droidTempDir = createFolderAndSystemProperty(DROID_TEMP_DIR, defaultDroidWorkingFolder); File logDir = createFolderAndSystemProperty(LOG_DIR, defaultDroidLogFolder); String logConfig = getSystemOrEnvironmentProperty(LOG4J_CONFIGURATION); if (logConfig == null) { File logConfigFile = createResourceFile(droidWorkDir, LOG4J_PROPERTIES, LOG4J_PROPERTIES); String logFileURI = logConfigFile.toURI().toString(); System.setProperty(LOG4J_CONFIGURATION, logFileURI); String consoleLogThreshold = getSystemOrEnvironmentProperty(CONSOLE_LOG_THRESHOLD); if (consoleLogThreshold == null || consoleLogThreshold.isEmpty()) { System.setProperty(CONSOLE_LOG_THRESHOLD, "INFO");
RuntimeConfig.configureRuntimeEnvironment(); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
try { droidWorkDir = createFolderAndSystemProperty(DROID_USER, defaultDroidWorkingFolder); droidTempDir = createFolderAndSystemProperty(DROID_TEMP_DIR, defaultDroidWorkingFolder); logDir = createFolderAndSystemProperty(LOG_DIR, defaultDroidLogFolder); } catch (final IOException e) { throw new RuntimeException(e); final String logConfig = getSystemOrEnvironmentProperty(LOG4J_CONFIGURATION); if (logConfig == null) { final Path logConfigFile = createResourceFile(droidWorkDir, LOG4J_PROPERTIES, LOG4J_PROPERTIES); String logFileURI = logConfigFile.toUri().toString(); System.setProperty(LOG4J_CONFIGURATION, logFileURI); final String consoleLogThreshold = getSystemOrEnvironmentProperty(CONSOLE_LOG_THRESHOLD); if (consoleLogThreshold == null || consoleLogThreshold.isEmpty()) { System.setProperty(CONSOLE_LOG_THRESHOLD, "INFO");
RuntimeConfig.configureRuntimeEnvironment(); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
/** * Main method for command line. * * @param args * the command line arguments * @throws CommandLineException if bad command * @throws CommandExecutionException if cannot execute command */ public static void main(final String[] args) throws CommandLineException { //BNO: The configureRuntimeEnvironment() method was getting called twice as it is also // the first call in commandLine.processExecution() below. This was causing a problem // with the log configuration file path getting appended to the current directory thereby // producing an invalid file path, e.g. C:\Projects\Droid\droid\file:\C:\Users\Brian\.droid6\log4j.properties. // There appears to be no other reason for the 2 calls so I have sinply removed the first call here. RuntimeConfig.configureRuntimeEnvironment(); int returnCode = 0; try (DroidCommandLine commandLine = new DroidCommandLine(args)) { returnCode = commandLine.processExecution(); } if (systemExit) { System.exit(returnCode); } }
private static Path createFolderAndSystemProperty(final String property, final Path defaultFolder) throws IOException { final String folderPath = getSystemOrEnvironmentProperty(property); final Path folder; if (folderPath == null || folderPath.isEmpty()) { folder = defaultFolder; } else { folder = Paths.get(folderPath); } Files.createDirectories(folder); System.setProperty(property, folder.toAbsolutePath().toString()); return folder; }