summaryrefslogtreecommitdiffstats
path: root/sonar-maven-plugin/src/main/java
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-02-04 17:54:57 +0300
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-02-04 19:48:41 +0300
commit547e8323146ec2f0f602ce6f4c325c9ed0ecbb18 (patch)
tree55e330b2b9959bdcf46ebde624f96766d6bb4d76 /sonar-maven-plugin/src/main/java
parentea8d694355aac5dc93de2650e11d802c6bb3e3d5 (diff)
downloadsonarqube-547e8323146ec2f0f602ce6f4c325c9ed0ecbb18.tar.gz
sonarqube-547e8323146ec2f0f602ce6f4c325c9ed0ecbb18.zip
Replace enum Environment by class EnvironmentInformation
* Each environment should provide key and version * Plugins for Maven 2.x and Maven 3.x have same key "Maven" and provide a real version of Maven
Diffstat (limited to 'sonar-maven-plugin/src/main/java')
-rw-r--r--sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java21
1 files changed, 17 insertions, 4 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 e78939fc39b..ab0123210f5 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
@@ -19,6 +19,8 @@
*/
package org.sonar.maven;
+import java.io.InputStream;
+
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
@@ -29,6 +31,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactCollector;
import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.RuntimeInformation;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -38,11 +41,9 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
import org.slf4j.LoggerFactory;
-import org.sonar.api.platform.Environment;
import org.sonar.batch.Batch;
import org.sonar.batch.MavenReactor;
-
-import java.io.InputStream;
+import org.sonar.batch.bootstrapper.EnvironmentInformation;
/**
* @goal sonar
@@ -129,6 +130,13 @@ public final class SonarMojo extends AbstractMojo {
*/
private MavenProjectBuilder projectBuilder;
+ /**
+ * @component
+ * @required
+ * @readonly
+ */
+ private RuntimeInformation runtimeInformation;
+
public void execute() throws MojoExecutionException, MojoFailureException {
initLogging();
executeBatch();
@@ -139,10 +147,15 @@ public final class SonarMojo extends AbstractMojo {
Batch batch = new Batch(getInitialConfiguration(),
reactor, session, project, getLog(), lifecycleExecutor, pluginManager, artifactFactory,
localRepository, artifactMetadataSource, artifactCollector, dependencyTreeBuilder,
- projectBuilder, Environment.MAVEN2, Maven2PluginExecutor.class);
+ projectBuilder, getEnvironmentInformation(), Maven2PluginExecutor.class);
batch.execute();
}
+ private EnvironmentInformation getEnvironmentInformation() {
+ String mavenVersion = runtimeInformation.getApplicationVersion().toString();
+ return new EnvironmentInformation("Maven", mavenVersion);
+ }
+
private void initLogging() throws MojoExecutionException {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator jc = new JoranConfigurator();