aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-maven3-plugin
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-maven3-plugin
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-maven3-plugin')
-rw-r--r--sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java47
1 files changed, 20 insertions, 27 deletions
diff --git a/sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java b/sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java
index 0c3767c98fc..d509c8728f2 100644
--- a/sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java
+++ b/sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java
@@ -34,11 +34,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
@@ -125,42 +127,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, artifactFactory,
- localRepository, artifactMetadataSource, artifactCollector, dependencyTreeBuilder,
- projectBuilder, getEnvironmentInformation(), Maven3PluginExecutor.class);
+ Batch batch = Batch.builder()
+ .setEnvironment(getEnvironmentInformation())
+ .setProjectReactor(reactor)
+ .addComponents(
+ session, getLog(), lifecycleExecutor, artifactFactory, localRepository, artifactMetadataSource, artifactCollector,
+ dependencyTreeBuilder, projectBuilder, Maven3PluginExecutor.class)
+ .build();
+
+ configureLogging(batch.getLoggingConfiguration());
batch.execute();
}
+ private void configureLogging(LoggingConfiguration logging) {
+ logging.setProperties((Map) session.getSystemProperties());
+ 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();
- }
}