summaryrefslogtreecommitdiffstats
path: root/sonar-maven-plugin/src/main/java
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-01-13 14:10:51 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-01-13 14:12:23 +0100
commit82e006da834823718fb6ac0b579dff772db2d599 (patch)
treec1d84ba76d8381548ce1f6fa0ad774d383d49d93 /sonar-maven-plugin/src/main/java
parent5a5dd47664de293a1f31743fed7c14e4f649b72e (diff)
downloadsonarqube-82e006da834823718fb6ac0b579dff772db2d599.tar.gz
sonarqube-82e006da834823718fb6ac0b579dff772db2d599.zip
Sanitize batch bootstrapper
- by default Logback is configured by batch, not by bootstrappers - ability to delegate logging to bootstrappers (require a SLF4J implementation)
Diffstat (limited to 'sonar-maven-plugin/src/main/java')
-rw-r--r--sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java48
1 files changed, 21 insertions, 27 deletions
diff --git a/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java b/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
index 9c3a42309ec..29200ffb1a0 100644
--- a/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
+++ b/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
@@ -35,11 +35,13 @@ import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.batch.Batch;
import org.sonar.batch.MavenProjectConverter;
+import org.sonar.batch.bootstrapper.Batch;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
import org.sonar.batch.bootstrapper.LoggingConfiguration;
+import java.util.Map;
+
/**
* @goal sonar
* @aggregator
@@ -132,41 +134,33 @@ public final class SonarMojo extends AbstractMojo {
*/
private RuntimeInformation runtimeInformation;
- /**
- * @parameter expression="${sonar.verbose}" default-value="false"
- */
- private boolean verbose;
-
- /**
- * @parameter expression="${sonar.showSql}" default-value="false"
- */
- private boolean showSql;
-
public void execute() throws MojoExecutionException, MojoFailureException {
- configureLogging();
- executeBatch();
- }
-
- private void executeBatch() throws MojoExecutionException {
ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects(), project);
ProjectReactor reactor = new ProjectReactor(def);
- Batch batch = new Batch(reactor, session, getLog(), lifecycleExecutor, pluginManager, artifactFactory,
- localRepository, artifactMetadataSource, artifactCollector, dependencyTreeBuilder,
- projectBuilder, getEnvironmentInformation(), Maven2PluginExecutor.class);
+ Batch batch = Batch.builder()
+ .setEnvironment(getEnvironmentInformation())
+ .setProjectReactor(reactor)
+ .addComponents(
+ session, getLog(), lifecycleExecutor, pluginManager, artifactFactory,
+ localRepository, artifactMetadataSource, artifactCollector, dependencyTreeBuilder,
+ projectBuilder, Maven2PluginExecutor.class)
+ .build();
+
+ configureLogging(batch.getLoggingConfiguration());
batch.execute();
}
+ private void configureLogging(LoggingConfiguration logging) {
+ logging.setProperties((Map) session.getExecutionProperties());
+ logging.setFormat(LoggingConfiguration.FORMAT_MAVEN);
+ if (getLog().isDebugEnabled()) {
+ logging.setVerbose(true);
+ }
+ }
+
private EnvironmentInformation getEnvironmentInformation() {
String mavenVersion = runtimeInformation.getApplicationVersion().toString();
return new EnvironmentInformation("Maven", mavenVersion);
}
-
- private void configureLogging() {
- LoggingConfiguration.create()
- .setVerbose(verbose || getLog().isDebugEnabled())
- .setShowSql(showSql)
- .setFormat(LoggingConfiguration.FORMAT_MAVEN)
- .configure();
- }
}