aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-01-03 11:09:55 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2013-01-03 18:36:15 +0100
commit67feeef54e28e7f61fcb4458a7024d7320b79626 (patch)
tree2626f0337f20644ceb13eebff92c229e5802f7f1 /src
parent93b9f302e3abe15bbaa5e7bc005392f2e7a7ad89 (diff)
downloadsonar-scanner-cli-67feeef54e28e7f61fcb4458a7024d7320b79626.tar.gz
sonar-scanner-cli-67feeef54e28e7f61fcb4458a7024d7320b79626.zip
Remove deprecations.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/sonar/runner/internal/batch/Launcher.java35
-rw-r--r--src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java4
-rw-r--r--src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java6
3 files changed, 35 insertions, 10 deletions
diff --git a/src/main/java/org/sonar/runner/internal/batch/Launcher.java b/src/main/java/org/sonar/runner/internal/batch/Launcher.java
index d966784..93626c2 100644
--- a/src/main/java/org/sonar/runner/internal/batch/Launcher.java
+++ b/src/main/java/org/sonar/runner/internal/batch/Launcher.java
@@ -23,17 +23,23 @@ import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import com.google.common.annotations.VisibleForTesting;
-import org.apache.commons.configuration.*;
+import org.apache.commons.configuration.CompositeConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.EnvironmentConfiguration;
+import org.apache.commons.configuration.MapConfiguration;
+import org.apache.commons.configuration.SystemConfiguration;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.utils.SonarException;
-import org.sonar.batch.Batch;
+import org.sonar.batch.bootstrapper.Batch;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
import org.sonar.runner.Runner;
import java.io.InputStream;
+import java.util.Iterator;
import java.util.List;
import java.util.Properties;
@@ -65,10 +71,29 @@ public class Launcher {
setContainerExtensionsOnProject(project);
String envKey = propertiesFromRunner.getProperty(Runner.PROPERTY_ENVIRONMENT_INFORMATION_KEY);
String envVersion = propertiesFromRunner.getProperty(Runner.PROPERTY_ENVIRONMENT_INFORMATION_VERSION);
- Batch batch = Batch.create(new ProjectReactor(project), initialConfiguration, new EnvironmentInformation(envKey, envVersion));
+ ProjectReactor projectReactor = new ProjectReactor(project);
+ if (initialConfiguration != null) {
+ projectReactor.getRoot().setProperties(convertToProperties(initialConfiguration));
+ }
+ Batch batch = Batch.builder()
+ .setProjectReactor(new ProjectReactor(project))
+ .setEnvironment(new EnvironmentInformation(envKey, envVersion))
+ .build();
batch.execute();
}
+ static Properties convertToProperties(Configuration configuration) {
+ Properties props = new Properties();
+ Iterator keys = configuration.getKeys();
+ while (keys.hasNext()) {
+ String key = (String) keys.next();
+ // Configuration#getString() automatically splits strings by comma separator.
+ String value = StringUtils.join(configuration.getStringArray(key), ",");
+ props.setProperty(key, value);
+ }
+ return props;
+ }
+
private void setContainerExtensionsOnProject(ProjectDefinition projectDefinition) {
for (Object extension : containerExtensions) {
projectDefinition.addContainerExtension(extension);
@@ -85,8 +110,8 @@ public class Launcher {
context.reset();
InputStream input = Batch.class.getResourceAsStream("/org/sonar/batch/logback.xml");
System.setProperty("ROOT_LOGGER_LEVEL", isDebug() ? "DEBUG" : "INFO");
- context.putProperty("SQL_LOGGER_LEVEL", getSqlLevel(initialConfiguration));// since 2.14. Ignored on previous versions.
- context.putProperty("SQL_RESULTS_LOGGER_LEVEL", getSqlResultsLevel(initialConfiguration));// since 2.14. Ignored on previous versions.
+ context.putProperty("SQL_LOGGER_LEVEL", getSqlLevel(initialConfiguration));
+ context.putProperty("SQL_RESULTS_LOGGER_LEVEL", getSqlResultsLevel(initialConfiguration));
try {
jc.doConfigure(input);
diff --git a/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java b/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java
index 5e2cb81..7e929ac 100644
--- a/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java
+++ b/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java
@@ -43,7 +43,7 @@ import java.util.Properties;
/**
* Class that creates a Sonar project definition based on a set of properties.
- *
+ *
* @since 1.5
*/
public final class SonarProjectBuilder {
@@ -134,7 +134,7 @@ public final class SonarProjectBuilder {
workDir = initModuleWorkDir(properties);
}
- ProjectDefinition definition = ProjectDefinition.create((Properties) properties.clone())
+ ProjectDefinition definition = ProjectDefinition.create().setProperties(properties)
.setBaseDir(baseDir)
.setWorkDir(workDir);
return definition;
diff --git a/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java b/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java
index 3c51885..366c20f 100644
--- a/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java
+++ b/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java
@@ -411,16 +411,16 @@ public class SonarProjectBuilderTest {
public void shouldFailIf2ModulesWithSameKey() {
Properties props = new Properties();
props.put("sonar.projectKey", "root");
- ProjectDefinition root = ProjectDefinition.create(props);
+ ProjectDefinition root = ProjectDefinition.create().setProperties(props);
Properties props1 = new Properties();
props1.put("sonar.projectKey", "mod1");
- root.addSubProject(ProjectDefinition.create(props1));
+ root.addSubProject(ProjectDefinition.create().setProperties(props1));
// Check uniqueness of a new module: OK
Properties props2 = new Properties();
props2.put("sonar.projectKey", "mod2");
- ProjectDefinition mod2 = ProjectDefinition.create(props2);
+ ProjectDefinition mod2 = ProjectDefinition.create().setProperties(props2);
SonarProjectBuilder.checkUniquenessOfChildKey(mod2, root);
// Now, add it and check again