diff options
Diffstat (limited to 'sonar-maven3-plugin/src')
-rw-r--r-- | sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java | 47 |
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(); - } } |