summaryrefslogtreecommitdiffstats
path: root/sonar-core-maven-plugin/src/main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-08-11 15:19:09 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2011-08-11 15:19:09 +0200
commit6f5eea36bd802edf9961e3e18ef7bc5e2d42b39d (patch)
treeb7230cf71fcc0559ca561b5df621a271670635e0 /sonar-core-maven-plugin/src/main
parentb75be91784305075e3c2bc00312dcb67377fef56 (diff)
downloadsonarqube-6f5eea36bd802edf9961e3e18ef7bc5e2d42b39d.tar.gz
sonarqube-6f5eea36bd802edf9961e3e18ef7bc5e2d42b39d.zip
SONAR-2689 Do not support the version 1.0-beta-1 of the Sonar maven plugin anymore
Diffstat (limited to 'sonar-core-maven-plugin/src/main')
-rw-r--r--sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java155
-rw-r--r--sonar-core-maven-plugin/src/main/java/org/sonar/maven2/Maven2PluginExecutor.java55
2 files changed, 2 insertions, 208 deletions
diff --git a/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java b/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java
index f81ea53d442..eb89d585abb 100644
--- a/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java
+++ b/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java
@@ -19,33 +19,9 @@
*/
package org.sonar.maven2;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.joran.JoranConfigurator;
-import ch.qos.logback.core.joran.spi.JoranException;
-import org.apache.commons.configuration.*;
-import org.apache.commons.io.IOUtils;
-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.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;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.PluginManager;
-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.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.EnvironmentInformation;
-
-import java.io.InputStream;
/**
* @goal internal
@@ -54,135 +30,8 @@ import java.io.InputStream;
*/
public final class BatchMojo extends AbstractMojo {
- /**
- * @parameter expression="${session}"
- * @required
- * @readonly
- */
- private MavenSession session;
-
- /**
- * @parameter expression="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- /**
- * @component
- * @required
- */
- private LifecycleExecutor lifecycleExecutor;
-
- /**
- * @component
- * @required
- */
- private PluginManager pluginManager;
-
- /**
- * The artifact factory to use.
- *
- * @component
- * @required
- * @readonly
- */
- private ArtifactFactory artifactFactory;
-
- /**
- * The artifact repository to use.
- *
- * @parameter expression="${localRepository}"
- * @required
- * @readonly
- */
- private ArtifactRepository localRepository;
-
- /**
- * The artifact metadata source to use.
- *
- * @component
- * @required
- * @readonly
- */
- private ArtifactMetadataSource artifactMetadataSource;
-
- /**
- * The artifact collector to use.
- *
- * @component
- * @required
- * @readonly
- */
- private ArtifactCollector artifactCollector;
-
- /**
- * The dependency tree builder to use.
- *
- * @component
- * @required
- * @readonly
- */
- private DependencyTreeBuilder dependencyTreeBuilder;
-
- /**
- * @component
- * @required
- * @readonly
- */
- private MavenProjectBuilder projectBuilder;
-
- /**
- * @component
- * @required
- * @readonly
- */
- private RuntimeInformation runtimeInformation;
-
public void execute() throws MojoExecutionException, MojoFailureException {
- initLogging();
- executeBatch();
- }
-
- private void executeBatch() throws MojoExecutionException {
- ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects(), project);
- ProjectReactor reactor = new ProjectReactor(def);
-
- Batch batch = Batch.create(reactor, getInitialConfiguration(), session, project,
- getLog(), lifecycleExecutor, pluginManager, artifactFactory,
- localRepository, artifactMetadataSource, artifactCollector,
- dependencyTreeBuilder, projectBuilder, getEnvironmentInformation(), Maven2PluginExecutor.class);
- batch.execute();
- }
-
- private EnvironmentInformation getEnvironmentInformation() {
- String mavenVersion = runtimeInformation.getApplicationVersion().toString();
- return new EnvironmentInformation("Maven", mavenVersion);
- }
-
- private Configuration getInitialConfiguration() {
- CompositeConfiguration configuration = new CompositeConfiguration();
- configuration.addConfiguration(new SystemConfiguration());
- configuration.addConfiguration(new EnvironmentConfiguration());
- configuration.addConfiguration(new MapConfiguration(project.getModel().getProperties()));
- return configuration;
- }
-
- private void initLogging() throws MojoExecutionException {
- LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- JoranConfigurator jc = new JoranConfigurator();
- jc.setContext(context);
- context.reset();
- InputStream input = getClass().getResourceAsStream("/org/sonar/batch/logback.xml");
- System.setProperty("ROOT_LOGGER_LEVEL", getLog().isDebugEnabled() ? "DEBUG" : "INFO");
- try {
- jc.doConfigure(input);
-
- } catch (JoranException e) {
- throw new MojoExecutionException("can not initialize logging", e);
-
- } finally {
- IOUtils.closeQuietly(input);
- }
+ throw new MojoExecutionException("The version 1.0-beta-1 of org.codehaus.mojo:sonar-maven-plugin is not supported anymore. "
+ + "Please upgrade to 1.0-beta-2 for Maven2 or 2.0-beta-2 for Maven3.");
}
}
diff --git a/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/Maven2PluginExecutor.java b/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/Maven2PluginExecutor.java
deleted file mode 100644
index ba4afc7120d..00000000000
--- a/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/Maven2PluginExecutor.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.maven2;
-
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.execution.ReactorManager;
-import org.apache.maven.lifecycle.LifecycleExecutor;
-import org.apache.maven.project.MavenProject;
-import org.sonar.batch.AbstractMavenPluginExecutor;
-
-import java.util.Arrays;
-
-public class Maven2PluginExecutor extends AbstractMavenPluginExecutor {
-
- private LifecycleExecutor lifecycleExecutor;
- private MavenSession mavenSession;
-
- public Maven2PluginExecutor(LifecycleExecutor le, MavenSession mavenSession) {
- this.lifecycleExecutor = le;
- this.mavenSession = mavenSession;
- }
-
- @Override
- public void concreteExecute(MavenProject pom, String goal) throws Exception {
- ReactorManager reactor = new ReactorManager(Arrays.asList(pom));
- MavenSession clonedSession = new MavenSession(mavenSession.getContainer(),
- mavenSession.getSettings(),
- mavenSession.getLocalRepository(),
- mavenSession.getEventDispatcher(),
- reactor,
- Arrays.asList(goal),
- mavenSession.getExecutionRootDirectory(),
- mavenSession.getExecutionProperties(),
- mavenSession.getStartTime());
- lifecycleExecutor.execute(clonedSession, reactor, clonedSession.getEventDispatcher());
- }
-
-}