]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6998 Remove injection of MavenProject in module IoC container 617/head
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 5 Nov 2015 11:30:18 +0000 (12:30 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 5 Nov 2015 17:37:51 +0000 (18:37 +0100)
plugins/sonar-batch-maven-plugin/pom.xml [deleted file]
plugins/sonar-batch-maven-plugin/src/main/java/org/sonar/plugins/batch/maven/MavenBatchPlugin.java [deleted file]
plugins/sonar-batch-maven-plugin/src/main/java/org/sonar/plugins/batch/maven/MavenProjectBuilder.java [deleted file]
pom.xml
sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java

diff --git a/plugins/sonar-batch-maven-plugin/pom.xml b/plugins/sonar-batch-maven-plugin/pom.xml
deleted file mode 100644 (file)
index 52fd352..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.sonarsource.sonarqube</groupId>
-    <artifactId>sonarqube</artifactId>
-    <version>5.3-SNAPSHOT</version>
-    <relativePath>../..</relativePath>
-  </parent>
-
-  <artifactId>sonar-batch-maven-plugin</artifactId>
-  <name>SonarQube :: Batch Maven Plugin</name>
-  <packaging>sonar-plugin</packaging>
-  <description>Inject MavenProject in each module.</description>
-
-  <dependencies>
-    <dependency>
-      <groupId>com.google.code.findbugs</groupId>
-      <artifactId>jsr305</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>sonar-plugin-api</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-core</artifactId>
-      <version>3.0</version>
-      <scope>provided</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
-        <artifactId>sonar-packaging-maven-plugin</artifactId>
-        <configuration>
-          <pluginKey>mavenbatch</pluginKey>
-          <pluginName>Maven Batch</pluginName>
-          <pluginClass>org.sonar.plugins.batch.maven.MavenBatchPlugin</pluginClass>
-          <pluginDescription>
-            <![CDATA[Inject MavenProject in each module.]]></pluginDescription>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/plugins/sonar-batch-maven-plugin/src/main/java/org/sonar/plugins/batch/maven/MavenBatchPlugin.java b/plugins/sonar-batch-maven-plugin/src/main/java/org/sonar/plugins/batch/maven/MavenBatchPlugin.java
deleted file mode 100644 (file)
index 5fd1c17..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.plugins.batch.maven;
-
-import org.sonar.api.SonarPlugin;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class MavenBatchPlugin extends SonarPlugin {
-
-  @Override
-  public List getExtensions() {
-    return Arrays.asList(MavenProjectBuilder.class);
-  }
-
-}
diff --git a/plugins/sonar-batch-maven-plugin/src/main/java/org/sonar/plugins/batch/maven/MavenProjectBuilder.java b/plugins/sonar-batch-maven-plugin/src/main/java/org/sonar/plugins/batch/maven/MavenProjectBuilder.java
deleted file mode 100644 (file)
index 6efa5cb..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.plugins.batch.maven;
-
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.project.MavenProject;
-import org.sonar.api.batch.SupportedEnvironment;
-import org.sonar.api.batch.bootstrap.ProjectBuilder;
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-
-import java.util.List;
-
-/**
- * Class that inject MavenProject in each module container
- */
-@SupportedEnvironment("maven")
-public class MavenProjectBuilder extends ProjectBuilder {
-
-  private final MavenSession mavenSession;
-
-  public MavenProjectBuilder(MavenSession mavenSession) {
-    this.mavenSession = mavenSession;
-  }
-
-  @Override
-  public void build(Context context) {
-    ProjectReactor reactor = context.projectReactor();
-    for (ProjectDefinition moduleDef : reactor.getProjects()) {
-      setMavenProjectIfApplicable(moduleDef);
-    }
-  }
-
-  private void setMavenProjectIfApplicable(ProjectDefinition definition) {
-    if (mavenSession != null) {
-      String moduleKey = definition.getKey();
-      for (MavenProject mavenModule : (List<MavenProject>) mavenSession.getProjects()) {
-        // FIXME assumption that moduleKey was not modified by user and follow convention <groupId>:<artifactId>
-        String mavenModuleKey = mavenModule.getGroupId() + ":" + mavenModule.getArtifactId();
-        if (mavenModuleKey.equals(moduleKey) && !definition.getContainerExtensions().contains(mavenModule)) {
-          definition.addContainerExtension(mavenModule);
-        }
-      }
-    }
-  }
-
-}
diff --git a/pom.xml b/pom.xml
index d8f301eea29fb33507efe74bf117eba34129d3eb..0c65672d3595c6c394c7541a4612b852775bee14 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,6 @@
     <module>sonar-ws</module>
     <module>sonar-testing-harness</module>
     <module>plugins/sonar-xoo-plugin</module>
-    <module>plugins/sonar-batch-maven-plugin</module>
   </modules>
 
   <organization>
           </exclusion>
         </exclusions>
       </dependency>
-      <dependency>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>maven-artifact</artifactId>
-        <version>2.0.7</version>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>maven-core</artifactId>
-        <version>2.0.7</version>
-      </dependency>
       <dependency>
         <groupId>com.ibm.icu</groupId>
         <artifactId>icu4j</artifactId>
index eeab1e08c2f15bac68e762acd69747e5ed36b436..3f5bf958a8b0b21180e6ef0f4cf95bb7f5a65cad 100644 (file)
@@ -112,7 +112,6 @@ public class ModuleScanContainer extends ComponentContainer {
       SensorsExecutor.class,
       InitializersExecutor.class,
       ProjectInitializer.class,
-      moduleDefinition.getContainerExtensions(),
 
       // file system
       ModuleInputFileCache.class,
index 101ad3290a2c6583f441f7dc3ff5741a7f6ab556..38cd625682daad4964f5b7aa932894ec02e086c9 100644 (file)
@@ -83,7 +83,6 @@ public class ProjectDefinition {
   private Map<String, String> properties = new HashMap<>();
   private ProjectDefinition parent = null;
   private List<ProjectDefinition> subProjects = new ArrayList<>();
-  private List<Object> containerExtensions = new ArrayList<>();
 
   private ProjectDefinition(Properties p) {
     for (Entry<Object, Object> entry : p.entrySet()) {
@@ -124,7 +123,7 @@ public class ProjectDefinition {
     return workDir;
   }
 
-  public ProjectDefinition setBuildDir( File d) {
+  public ProjectDefinition setBuildDir(File d) {
     this.buildDir = d;
     return this;
   }
@@ -553,23 +552,6 @@ public class ProjectDefinition {
     appendProperty(LIBRARIES_PROPERTY, path);
   }
 
-  /**
-   * Adds an extension, which would be available in PicoContainer during analysis of this project.
-   *
-   * @since 2.8
-   */
-  public ProjectDefinition addContainerExtension(Object extension) {
-    containerExtensions.add(extension);
-    return this;
-  }
-
-  /**
-   * @since 2.8
-   */
-  public List<Object> getContainerExtensions() {
-    return containerExtensions;
-  }
-
   /**
    * @since 2.8
    */