Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* SonarQube Runner - CLI - Distribution
* Copyright (C) 2011 SonarSource
* [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
package org.sonar.runner.cli;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
class Conf {
private static final String RUNNER_HOME = "runner.home";
private static final String RUNNER_SETTINGS = "runner.settings";
private static final String PROJECT_HOME = "project.home";
private static final String PROJECT_SETTINGS = "project.settings";
private static final String PROPERTY_MODULES = "sonar.modules";
private static final String PROPERTY_PROJECT_BASEDIR = "sonar.projectBaseDir";
private static final String PROPERTY_PROJECT_CONFIG_FILE = "sonar.projectConfigFile";
private static final String SONAR_PROJECT_PROPERTIES_FILENAME = "sonar-project.properties";
private final Cli cli;
private final Logs logger;
Conf(Cli cli, Logs logger) {
this.cli = cli;
this.logger = logger;
}
Properties properties() throws IOException {
Properties result = new Properties();
result.putAll(loadGlobalProperties());
result.putAll(loadProjectProperties());
result.putAll(System.getProperties());
result.putAll(cli.properties());
result.remove(PROJECT_HOME);
return result;
}
private Properties loadGlobalProperties() throws IOException {
File settingsFile = locatePropertiesFile(cli.properties(), RUNNER_HOME, "conf/sonar-runner.properties", RUNNER_SETTINGS);
if (settingsFile != null && settingsFile.isFile() && settingsFile.exists()) {
logger.info("Runner configuration file: " + settingsFile.getAbsolutePath());
return toProperties(settingsFile);
}
logger.info("Runner configuration file: NONE");
return new Properties();
}
private Properties loadProjectProperties() throws IOException {
Properties cliProps = cli.properties();
File rootSettingsFile = locatePropertiesFile(cliProps, cliProps.containsKey(PROPERTY_PROJECT_BASEDIR) ? PROPERTY_PROJECT_BASEDIR : PROJECT_HOME,
SONAR_PROJECT_PROPERTIES_FILENAME,
PROJECT_SETTINGS);
if (rootSettingsFile != null && rootSettingsFile.isFile() && rootSettingsFile.exists()) {
logger.info("Project configuration file: " + rootSettingsFile.getAbsolutePath());
Properties projectProps = new Properties();
Properties rootProps = toProperties(rootSettingsFile);
projectProps.putAll(rootProps);
initRootProjectBaseDir(cliProps, rootProps);
loadModulesProperties(rootProps, projectProps, "");
return projectProps;
}
logger.info("Project configuration file: NONE");
return new Properties();
}
private static void initRootProjectBaseDir(Properties cliProps, Properties rootProps) {
if (!cliProps.containsKey(PROPERTY_PROJECT_BASEDIR)) {
String baseDir = cliProps.getProperty(PROJECT_HOME);
rootProps.put(PROPERTY_PROJECT_BASEDIR, baseDir);
} else {
rootProps.put(PROPERTY_PROJECT_BASEDIR, cliProps.getProperty(PROPERTY_PROJECT_BASEDIR));
}
}
private void loadModulesProperties(Properties parentProps, Properties projectProps, String prefix) {
File parentBaseDir = new File(parentProps.getProperty(PROPERTY_PROJECT_BASEDIR));
if (parentProps.containsKey(PROPERTY_MODULES)) {
for (String module : getListFromProperty(parentProps, PROPERTY_MODULES)) {
Properties moduleProps = extractModuleProperties(module, parentProps);
moduleProps = loadChildConfigFile(parentBaseDir, moduleProps, module);
// the child project may have children as well
loadModulesProperties(moduleProps, projectProps, prefix + module + ".");
// and finally add this child properties to global props
merge(projectProps, prefix, module, moduleProps);
}
}
}
private static void merge(Properties projectProps, String prefix, String module, Properties moduleProps) {
for (Map.Entry