From 266e3139c3ef6112d43d3422489a0654937b1816 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 5 Nov 2015 12:30:18 +0100 Subject: [PATCH] SONAR-6998 Remove injection of MavenProject in module IoC container --- plugins/sonar-batch-maven-plugin/pom.xml | 51 --------------- .../plugins/batch/maven/MavenBatchPlugin.java | 34 ---------- .../batch/maven/MavenProjectBuilder.java | 64 ------------------- pom.xml | 11 ---- .../sonar/batch/scan/ModuleScanContainer.java | 1 - .../batch/bootstrap/ProjectDefinition.java | 20 +----- 6 files changed, 1 insertion(+), 180 deletions(-) delete mode 100644 plugins/sonar-batch-maven-plugin/pom.xml delete mode 100644 plugins/sonar-batch-maven-plugin/src/main/java/org/sonar/plugins/batch/maven/MavenBatchPlugin.java delete mode 100644 plugins/sonar-batch-maven-plugin/src/main/java/org/sonar/plugins/batch/maven/MavenProjectBuilder.java diff --git a/plugins/sonar-batch-maven-plugin/pom.xml b/plugins/sonar-batch-maven-plugin/pom.xml deleted file mode 100644 index 52fd352bfb2..00000000000 --- a/plugins/sonar-batch-maven-plugin/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - - - org.sonarsource.sonarqube - sonarqube - 5.3-SNAPSHOT - ../.. - - - sonar-batch-maven-plugin - SonarQube :: Batch Maven Plugin - sonar-plugin - Inject MavenProject in each module. - - - - com.google.code.findbugs - jsr305 - provided - - - ${project.groupId} - sonar-plugin-api - provided - - - org.apache.maven - maven-core - 3.0 - provided - - - - - - - org.sonarsource.sonar-packaging-maven-plugin - sonar-packaging-maven-plugin - - mavenbatch - Maven Batch - org.sonar.plugins.batch.maven.MavenBatchPlugin - - - - - - - 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 index 5fd1c17484d..00000000000 --- a/plugins/sonar-batch-maven-plugin/src/main/java/org/sonar/plugins/batch/maven/MavenBatchPlugin.java +++ /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 index 6efa5cbfc37..00000000000 --- a/plugins/sonar-batch-maven-plugin/src/main/java/org/sonar/plugins/batch/maven/MavenProjectBuilder.java +++ /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) mavenSession.getProjects()) { - // FIXME assumption that moduleKey was not modified by user and follow convention : - 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 d8f301eea29..0c65672d359 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,6 @@ sonar-ws sonar-testing-harness plugins/sonar-xoo-plugin - plugins/sonar-batch-maven-plugin @@ -831,16 +830,6 @@ - - org.apache.maven - maven-artifact - 2.0.7 - - - org.apache.maven - maven-core - 2.0.7 - com.ibm.icu icu4j diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java index eeab1e08c2f..3f5bf958a8b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java @@ -112,7 +112,6 @@ public class ModuleScanContainer extends ComponentContainer { SensorsExecutor.class, InitializersExecutor.class, ProjectInitializer.class, - moduleDefinition.getContainerExtensions(), // file system ModuleInputFileCache.class, diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java index 101ad3290a2..38cd625682d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java @@ -83,7 +83,6 @@ public class ProjectDefinition { private Map properties = new HashMap<>(); private ProjectDefinition parent = null; private List subProjects = new ArrayList<>(); - private List containerExtensions = new ArrayList<>(); private ProjectDefinition(Properties p) { for (Entry 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 getContainerExtensions() { - return containerExtensions; - } - /** * @since 2.8 */ -- 2.39.5