aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-maven3-plugin
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-maven3-plugin
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-maven3-plugin')
-rw-r--r--sonar-maven3-plugin/pom.xml6
-rw-r--r--sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java21
2 files changed, 23 insertions, 4 deletions
diff --git a/sonar-maven3-plugin/pom.xml b/sonar-maven3-plugin/pom.xml
index 020128773a8..5ccb6c95fa7 100644
--- a/sonar-maven3-plugin/pom.xml
+++ b/sonar-maven3-plugin/pom.xml
@@ -47,6 +47,12 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>${maven.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>${maven.version}</version>
<scope>provided</scope>
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 058bc886253..baca606b874 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
@@ -19,6 +19,8 @@
*/
package org.sonar.maven3;
+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;
@@ -37,11 +40,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
@@ -122,6 +123,13 @@ public final class SonarMojo extends AbstractMojo {
*/
private MavenProjectBuilder projectBuilder;
+ /**
+ * @component
+ * @required
+ * @readonly
+ */
+ private RuntimeInformation runtimeInformation;
+
public void execute() throws MojoExecutionException, MojoFailureException {
initLogging();
executeBatch();
@@ -132,10 +140,15 @@ public final class SonarMojo extends AbstractMojo {
Batch batch = new Batch(getInitialConfiguration(),
reactor, session, project, getLog(), lifecycleExecutor, artifactFactory,
localRepository, artifactMetadataSource, artifactCollector, dependencyTreeBuilder,
- projectBuilder, Environment.MAVEN3, Maven3PluginExecutor.class);
+ projectBuilder, getEnvironmentInformation(), Maven3PluginExecutor.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();