]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2689 Do not support the version 1.0-beta-1 of the Sonar maven plugin anymore
authorSimon Brandhof <simon.brandhof@gmail.com>
Thu, 11 Aug 2011 13:19:09 +0000 (15:19 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Thu, 11 Aug 2011 13:19:09 +0000 (15:19 +0200)
sonar-core-maven-plugin/pom.xml
sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java
sonar-core-maven-plugin/src/main/java/org/sonar/maven2/Maven2PluginExecutor.java [deleted file]
sonar-core-maven-plugin/src/test/resources/logback-text.xml [deleted file]
sonar-server/src/main/java/org/sonar/server/mavendeployer/Artifact.java
sonar-server/src/main/java/org/sonar/server/mavendeployer/MavenRepository.java
sonar-server/src/main/java/org/sonar/server/mavendeployer/Mojo.java
sonar-server/src/main/resources/org/sonar/server/mavendeployer/sonar-core-maven-plugin.template

index 9fb3b019aac2f9e3288ecc9bb27e48a4cf07e55a..3f87431272220c72fabdca2129ba19e3f35f7b5f 100644 (file)
 
     -->
 
-    <dependency>
-      <groupId>org.apache.maven.shared</groupId>
-      <artifactId>maven-dependency-tree</artifactId>
-      <version>1.2</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.sonar</groupId>
-      <artifactId>sonar-plugin-api</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.sonar</groupId>
-      <artifactId>sonar-batch</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-classic</artifactId>
-    </dependency>   
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
        <version>2.0.7</version>
       <scope>provided</scope>
     </dependency>
-    <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.sonar</groupId>
-      <artifactId>sonar-plugin-api</artifactId>
-      <version>${project.version}</version>
-      <scope>test</scope>
-      <type>test-jar</type>
-    </dependency>
   </dependencies>
   <build>
     <plugins>
index f81ea53d4426c0c485b8572fd31897bade231c62..eb89d585abb18418ef5b2d3049328cdd99338498 100644 (file)
  */
 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 (file)
index ba4afc7..0000000
+++ /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());
-  }
-
-}
diff --git a/sonar-core-maven-plugin/src/test/resources/logback-text.xml b/sonar-core-maven-plugin/src/test/resources/logback-text.xml
deleted file mode 100644 (file)
index e9e78e5..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<configuration>
-
-  <appender name="STDOUT"
-            class="ch.qos.logback.core.ConsoleAppender">
-    <layout class="ch.qos.logback.classic.PatternLayout">
-      <pattern>
-        %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n
-      </pattern>
-    </layout>
-  </appender>
-
-  <logger name="org.sonar.DBSTATISTICS">
-    <level value="INFO"/>
-  </logger>
-
-  <root>
-    <level value="WARN"/>
-    <appender-ref ref="STDOUT"/>
-  </root>
-
-</configuration>
\ No newline at end of file
index cf1793dd085308207581db6db37279cdd7317819..1c953d013c09745f1fc5ab42756796c5c57c7cfb 100644 (file)
@@ -36,26 +36,18 @@ public class Artifact {
   private String groupId;
   private String artifactId;
   protected String version;
-  private Artifact[] dependencies;
   protected File jar;
   private String packaging;
 
-  public Artifact(String groupId, String artifactId, String version, String packaging, File jar, Artifact... deps) {
+  public Artifact(String groupId, String artifactId, String version, String packaging, File jar) {
     this.artifactId = artifactId;
     this.groupId = groupId;
     this.version = version;
-    this.dependencies = deps;
     this.jar = jar;
     this.packaging = packaging;
   }
 
-  public void deployTo(File rootDir, boolean deployDependencies) throws IOException {
-    if (deployDependencies && dependencies != null) {
-      for (Artifact dependency : dependencies) {
-        dependency.deployTo(rootDir, true);
-      }
-    }
-
+  public void deployTo(File rootDir) throws IOException {
     File dir = createDir(rootDir);
     savePom(dir);
     saveMetadata(dir);
@@ -85,18 +77,6 @@ public class Artifact {
     return version;
   }
 
-  public Artifact[] getDependencies() {
-    return dependencies;
-  }
-
-  public File getJar() {
-    return jar;
-  }
-
-  public String getPackaging() {
-    return packaging;
-  }
-
   private void saveJar(File dir) throws IOException {
     if (jar != null) {
       copyTo(dir);
@@ -125,23 +105,13 @@ public class Artifact {
   }
 
   public String getPom() throws IOException {
-    return transformFromTemplatePath(getTemplatePath(), getDependenciesAsString());
+    return transformFromTemplatePath(getTemplatePath());
   }
 
   protected String getTemplatePath() {
     return "/org/sonar/server/mavendeployer/pom.template";
   }
 
-  private String getDependenciesAsString() throws IOException {
-    StringBuilder sb = new StringBuilder();
-    if (dependencies != null) {
-      for (Artifact dependency : dependencies) {
-        sb.append(dependency.getXmlDefinition());
-      }
-    }
-    return sb.toString();
-  }
-
   @Override
   public boolean equals(Object o) {
     if (this == o) {
@@ -179,11 +149,7 @@ public class Artifact {
     FileUtils.writeStringToFile(metadataFile, getMetadata(), CharEncoding.UTF_8);
   }
 
-  protected String transformFromTemplatePath(String templatePath) throws IOException {
-    return transformFromTemplatePath(templatePath, "");
-  }
-
-  protected final String transformFromTemplatePath(String templatePath, String depsXml) throws IOException {
+  protected final String transformFromTemplatePath(String templatePath) throws IOException {
     InputStream template = this.getClass().getResourceAsStream(templatePath);
     try {
       String content = IOUtils.toString(template);
@@ -192,7 +158,6 @@ public class Artifact {
       content = StringUtils.replace(content, "$version", version);
       content = StringUtils.replace(content, "$timestamp", version);
       content = StringUtils.replace(content, "$packaging", packaging);
-      content = StringUtils.replace(content, "$dependencies", StringUtils.defaultString(depsXml, ""));
       return content;
 
     } finally {
index 8dbd3e57d598b272ce94089e20422062a57bc507..22455c1a0575c04bd5e0e64711d342f2586ea3d0 100644 (file)
@@ -52,7 +52,7 @@ public class MavenRepository {
   public void start() {
     try {
       Artifact maven2Plugin = Mojo.createMaven2Plugin(serverId, installation.getMaven2Plugin());
-      maven2Plugin.deployTo(rootDir, false);
+      maven2Plugin.deployTo(rootDir);
 
     } catch (IOException e) {
       throw new RuntimeException(e);
index bd90adea32124339d32beeca9bd573b1f0be5be9..615dbf4ae528d92fe80b0ed1ae636c4087febc15 100644 (file)
@@ -28,16 +28,12 @@ import java.io.IOException;
 
 public final class Mojo extends Artifact {
 
-  private Mojo(String artifactId, String version, File jar, Artifact... deps) {
-    super(BASE_GROUP_ID, artifactId, version, "maven-plugin", jar, deps);
+  private Mojo(String artifactId, String version, File jar) {
+    super(BASE_GROUP_ID, artifactId, version, "maven-plugin", jar);
   }
 
-  public static Mojo createMaven2Plugin(String version, File jar, Artifact... deps) {
-    return new Mojo("sonar-core-maven-plugin", version, jar, deps);
-  }
-
-  public static Mojo createMaven3Plugin(String version, File jar, Artifact... deps) {
-    return new Mojo("sonar-core-maven3-plugin", version, jar, deps);
+  public static Mojo createMaven2Plugin(String version, File jar) {
+    return new Mojo("sonar-core-maven-plugin", version, jar);
   }
 
   @Override
index 1340868f93b51bfd6f338b15a94b1a81f33b9a9d..0c59a937c5d626f91c94c811a73736b856b5f2f1 100644 (file)
@@ -9,26 +9,6 @@
     <status>deployed</status>
   </distributionManagement>
   <dependencies>
-    <dependency>
-      <groupId>org.apache.maven.shared</groupId>
-      <artifactId>maven-dependency-tree</artifactId>
-      <version>1.2</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.sonar</groupId>
-      <artifactId>sonar-batch</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-       <dependency>
-           <groupId>ch.qos.logback</groupId>
-           <artifactId>logback-classic</artifactId>
-           <version>0.9.15</version>
-         </dependency>
-         <dependency>
-           <groupId>org.slf4j</groupId>
-           <artifactId>slf4j-api</artifactId>
-           <version>1.5.6</version>
-         </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
       <version>2.0.7</version>
       <scope>provided</scope>
     </dependency>
-    <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-      <version>2.4</version>
-    </dependency>
-
-    $dependencies
-    
   </dependencies>
 </project>
\ No newline at end of file