From: Julien HENRY Date: Thu, 3 Apr 2014 16:19:46 +0000 (+0200) Subject: Fix some quality flaws X-Git-Tag: 2.5-rc1~106 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b6cc065950fcaaf1bc22aded8ccce1bfd00219cc;p=sonar-scanner-cli.git Fix some quality flaws --- diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/ForkedRunner.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/ForkedRunner.java index 91cc626..9dff8ed 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/api/ForkedRunner.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/ForkedRunner.java @@ -154,11 +154,11 @@ public class ForkedRunner extends Runner { javaExecutable = new Os().thisJavaExe().getAbsolutePath(); } Command command = Command.builder() - .setExecutable(javaExecutable) - .addEnvVariables(jvmEnvVariables) - .addArguments(jvmArguments) - .addArguments("-cp", jarFile.getAbsolutePath(), BatchLauncherMain.class.getName(), propertiesFile.getAbsolutePath()) - .build(); + .setExecutable(javaExecutable) + .addEnvVariables(jvmEnvVariables) + .addArguments(jvmArguments) + .addArguments("-cp", jarFile.getAbsolutePath(), BatchLauncherMain.class.getName(), propertiesFile.getAbsolutePath()) + .build(); return new ForkCommand(command, jarFile, propertiesFile); } @@ -186,10 +186,6 @@ public class ForkedRunner extends Runner { private void fork(ForkCommand forkCommand) { if (stdOut == null) { stdOut = new PrintStreamConsumer(System.out); - stdOut = new PrintStreamConsumer(System.out); - stdOut = new PrintStreamConsumer(System.out); - stdOut = new PrintStreamConsumer(System.out); - stdOut = new PrintStreamConsumer(System.out); } if (stdErr == null) { stdErr = new PrintStreamConsumer(System.err); diff --git a/sonar-runner-dist/src/main/java/org/sonar/runner/Conf.java b/sonar-runner-dist/src/main/java/org/sonar/runner/Conf.java index c76176b..6ba9d72 100644 --- a/sonar-runner-dist/src/main/java/org/sonar/runner/Conf.java +++ b/sonar-runner-dist/src/main/java/org/sonar/runner/Conf.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.text.MessageFormat; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; @@ -37,6 +38,7 @@ class Conf { 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; @@ -66,7 +68,8 @@ class Conf { 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", + 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()) { Logs.info("Project configuration file: " + rootSettingsFile.getAbsolutePath()); @@ -126,6 +129,7 @@ class Conf { } } else if (moduleProps.containsKey(PROPERTY_PROJECT_CONFIG_FILE)) { baseDir = loadPropsFile(parentBaseDir, moduleProps, moduleId); + setProjectBaseDir(baseDir, moduleProps, moduleId); moduleProps.remove(PROPERTY_PROJECT_CONFIG_FILE); } else { baseDir = new File(parentBaseDir, moduleId); @@ -138,7 +142,7 @@ class Conf { private static void setProjectBaseDir(File baseDir, Properties childProps, String moduleId) { if (!baseDir.isDirectory()) { - throw new IllegalStateException("The base directory of the module '" + moduleId + "' does not exist: " + baseDir.getAbsolutePath()); + throw new IllegalStateException(MessageFormat.format("The base directory of the module ''{0}'' does not exist: {1}", moduleId, baseDir.getAbsolutePath())); } childProps.put(PROPERTY_PROJECT_BASEDIR, baseDir.getAbsolutePath()); } @@ -222,7 +226,7 @@ class Conf { } private void tryToFindAndLoadPropsFile(File baseDir, Properties moduleProps, String moduleId) { - File propertyFile = new File(baseDir, "sonar-project.properties"); + File propertyFile = new File(baseDir, SONAR_PROJECT_PROPERTIES_FILENAME); if (propertyFile.isFile()) { Properties propsFromFile = toProperties(propertyFile); for (Entry entry : propsFromFile.entrySet()) {