From: Julien HENRY Date: Thu, 3 Apr 2014 15:09:44 +0000 (+0200) Subject: SONAR-5186 Drop support of "sonar.phase" X-Git-Tag: 4.3~151 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=47ce28ff36c4d02b604e86632c7358201c93c5c5;p=sonarqube.git SONAR-5186 Drop support of "sonar.phase" --- diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/PhaseExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/PhaseExecutor.java index 840c9ec8869..0ba16ea66d7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/PhaseExecutor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/PhaseExecutor.java @@ -33,7 +33,6 @@ import org.sonar.batch.issue.ignore.scanner.IssueExclusionsLoader; import org.sonar.batch.rule.QProfileVerifier; import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; import org.sonar.batch.scan.filesystem.FileSystemLogger; -import org.sonar.batch.scan.maven.MavenPhaseExecutor; import org.sonar.batch.scan.maven.MavenPluginsConfigurator; import org.sonar.batch.scan.report.JsonReport; @@ -46,7 +45,6 @@ public final class PhaseExecutor { private final EventBus eventBus; private final Phases phases; private final DecoratorsExecutor decoratorsExecutor; - private final MavenPhaseExecutor mavenPhaseExecutor; private final MavenPluginsConfigurator mavenPluginsConfigurator; private final PostJobsExecutor postJobsExecutor; private final InitializersExecutor initializersExecutor; @@ -63,7 +61,7 @@ public final class PhaseExecutor { private final QProfileVerifier profileVerifier; private final IssueExclusionsLoader issueExclusionsLoader; - public PhaseExecutor(Phases phases, DecoratorsExecutor decoratorsExecutor, MavenPhaseExecutor mavenPhaseExecutor, + public PhaseExecutor(Phases phases, DecoratorsExecutor decoratorsExecutor, MavenPluginsConfigurator mavenPluginsConfigurator, InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor, PersistenceManager persistenceManager, SensorContext sensorContext, DefaultIndex index, @@ -72,7 +70,6 @@ public final class PhaseExecutor { IssueExclusionsLoader issueExclusionsLoader) { this.phases = phases; this.decoratorsExecutor = decoratorsExecutor; - this.mavenPhaseExecutor = mavenPhaseExecutor; this.mavenPluginsConfigurator = mavenPluginsConfigurator; this.postJobsExecutor = postJobsExecutor; this.initializersExecutor = initializersExecutor; @@ -91,18 +88,18 @@ public final class PhaseExecutor { this.issueExclusionsLoader = issueExclusionsLoader; } - public PhaseExecutor(Phases phases, DecoratorsExecutor decoratorsExecutor, MavenPhaseExecutor mavenPhaseExecutor, + public PhaseExecutor(Phases phases, DecoratorsExecutor decoratorsExecutor, MavenPluginsConfigurator mavenPluginsConfigurator, InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor, PersistenceManager persistenceManager, SensorContext sensorContext, DefaultIndex index, EventBus eventBus, ProjectInitializer pi, ScanPersister[] persisters, FileSystemLogger fsLogger, JsonReport jsonReport, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier, IssueExclusionsLoader issueExclusionsLoader) { - this(phases, decoratorsExecutor, mavenPhaseExecutor, mavenPluginsConfigurator, initializersExecutor, postJobsExecutor, + this(phases, decoratorsExecutor, mavenPluginsConfigurator, initializersExecutor, postJobsExecutor, sensorsExecutor, persistenceManager, sensorContext, index, eventBus, null, pi, persisters, fsLogger, jsonReport, fs, profileVerifier, issueExclusionsLoader); } public static Collection getPhaseClasses() { - return Lists.newArrayList(DecoratorsExecutor.class, MavenPhaseExecutor.class, MavenPluginsConfigurator.class, + return Lists.newArrayList(DecoratorsExecutor.class, MavenPluginsConfigurator.class, PostJobsExecutor.class, SensorsExecutor.class, InitializersExecutor.class, ProjectInitializer.class, UpdateStatusJob.class); } @@ -188,7 +185,6 @@ public final class PhaseExecutor { if (phases.isEnabled(Phases.Phase.MAVEN)) { eventBus.fireEvent(new MavenPhaseEvent(true)); mavenPluginsConfigurator.execute(module); - mavenPhaseExecutor.execute(module); eventBus.fireEvent(new MavenPhaseEvent(false)); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPhaseExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPhaseExecutor.java deleted file mode 100644 index 2712e2d34d5..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPhaseExecutor.java +++ /dev/null @@ -1,53 +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.batch.scan.maven; - -import com.google.common.base.Strings; -import org.sonar.api.BatchComponent; -import org.sonar.api.config.Settings; -import org.sonar.api.database.DatabaseSession; -import org.sonar.api.resources.Project; -import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; - -public class MavenPhaseExecutor implements BatchComponent { - - public static final String PROP_PHASE = "sonar.phase"; - - private final MavenPluginExecutor executor; - private final DefaultModuleFileSystem fs; - private final Settings settings; - private final DatabaseSession session; - - public MavenPhaseExecutor(DefaultModuleFileSystem fs, MavenPluginExecutor executor, Settings settings, DatabaseSession session) { - this.fs = fs; - this.executor = executor; - this.settings = settings; - this.session = session; - } - - public void execute(Project project) { - // SONAR-2965 In case the Maven phase takes too much time we close the session to not face a timeout - session.commitAndClose(); - String mavenPhase = settings.getString(PROP_PHASE); - if (!Strings.isNullOrEmpty(mavenPhase)) { - executor.execute(project, fs, mavenPhase); - } - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/maven/MavenPhaseExecutorTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/maven/MavenPhaseExecutorTest.java deleted file mode 100644 index 7cae730d3b9..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/maven/MavenPhaseExecutorTest.java +++ /dev/null @@ -1,60 +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.batch.scan.maven; - -import org.junit.Test; -import org.sonar.api.config.Settings; -import org.sonar.api.database.DatabaseSession; -import org.sonar.api.resources.Project; -import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; - -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -public class MavenPhaseExecutorTest { - - @Test - public void doNothingIfNoPhase() { - DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class); - MavenPluginExecutor mavenPluginExecutor = mock(MavenPluginExecutor.class); - MavenPhaseExecutor phaseExecutor = new MavenPhaseExecutor(fs, mavenPluginExecutor, new Settings(), mock(DatabaseSession.class)); - - Project project = new Project("key"); - phaseExecutor.execute(project); - - verify(mavenPluginExecutor, never()).execute(eq(project), eq(fs), anyString()); - } - - @Test - public void executePhase() { - DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class); - MavenPluginExecutor mavenPluginExecutor = mock(MavenPluginExecutor.class); - Settings settings = new Settings().setProperty(MavenPhaseExecutor.PROP_PHASE, "foo"); - MavenPhaseExecutor phaseExecutor = new MavenPhaseExecutor(fs, mavenPluginExecutor, settings, mock(DatabaseSession.class)); - - Project project = mock(Project.class); - phaseExecutor.execute(project); - - verify(mavenPluginExecutor).execute(project, fs, "foo"); - } -}