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;
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;
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,
IssueExclusionsLoader issueExclusionsLoader) {
this.phases = phases;
this.decoratorsExecutor = decoratorsExecutor;
- this.mavenPhaseExecutor = mavenPhaseExecutor;
this.mavenPluginsConfigurator = mavenPluginsConfigurator;
this.postJobsExecutor = postJobsExecutor;
this.initializersExecutor = initializersExecutor;
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<Class> getPhaseClasses() {
- return Lists.<Class>newArrayList(DecoratorsExecutor.class, MavenPhaseExecutor.class, MavenPluginsConfigurator.class,
+ return Lists.<Class>newArrayList(DecoratorsExecutor.class, MavenPluginsConfigurator.class,
PostJobsExecutor.class, SensorsExecutor.class,
InitializersExecutor.class, ProjectInitializer.class, UpdateStatusJob.class);
}
if (phases.isEnabled(Phases.Phase.MAVEN)) {
eventBus.fireEvent(new MavenPhaseEvent(true));
mavenPluginsConfigurator.execute(module);
- mavenPhaseExecutor.execute(module);
eventBus.fireEvent(new MavenPhaseEvent(false));
}
}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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");
- }
-}