diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-07-15 16:17:21 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-07-15 16:17:46 +0200 |
commit | a2eee9d6cd812e3a0a37491bc7124add940d4995 (patch) | |
tree | 93aa2caefb56ff86dfcefba3115916f8083d50ac /sonar-maven-plugin/src/main | |
parent | 9f2fd2ac35aedde9c244f76bd948bf5011b9cbb9 (diff) | |
download | sonarqube-a2eee9d6cd812e3a0a37491bc7124add940d4995.tar.gz sonarqube-a2eee9d6cd812e3a0a37491bc7124add940d4995.zip |
SONAR-4493 End of support of Maven 2.0 and 2.1
Diffstat (limited to 'sonar-maven-plugin/src/main')
-rw-r--r-- | sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java | 16 |
1 files changed, 11 insertions, 5 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 dc1c764a51e..14213720c23 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 @@ -23,6 +23,7 @@ import org.apache.maven.artifact.factory.ArtifactFactory; 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.artifact.versioning.ArtifactVersion; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.RuntimeInformation; import org.apache.maven.lifecycle.LifecycleExecutor; @@ -122,13 +123,18 @@ public final class SonarMojo extends AbstractMojo { * @component * @required * @readonly + * @VisibleForTesting */ - private RuntimeInformation runtimeInformation; + RuntimeInformation runtimeInformation; public void execute() throws MojoExecutionException, MojoFailureException { + ArtifactVersion mavenVersion = getMavenVersion(); + if (mavenVersion.getMajorVersion() == 2 && mavenVersion.getMinorVersion() < 2) { + throw new MojoExecutionException("Please use at least Maven 2.2.x to perform SonarQube analysis (current version is " + mavenVersion.toString() + ")"); + } EmbeddedRunner runner = EmbeddedRunner.create() - .setApp("Maven", getMavenVersion()) + .setApp("Maven", mavenVersion.toString()) .addProperties(session.getExecutionProperties()) .addProperties(project.getModel().getProperties()) // Add user properties (ie command line arguments -Dsonar.xxx=yyyy) in last position to override all other @@ -159,15 +165,15 @@ public final class SonarMojo extends AbstractMojo { // Include everything else .unmask(""); runner.addExtensions(session, getLog(), lifecycleExecutor, artifactFactory, localRepository, artifactMetadataSource, artifactCollector, - dependencyTreeBuilder, projectBuilder); + dependencyTreeBuilder, projectBuilder); if (getLog().isDebugEnabled()) { runner.setProperty("sonar.verbose", "true"); } runner.execute(); } - private String getMavenVersion() { - return runtimeInformation.getApplicationVersion().toString(); + private ArtifactVersion getMavenVersion() { + return runtimeInformation.getApplicationVersion(); } public static String toString(Object obj) { |