aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/main/java/org/sonar
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java3
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java25
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/maven/DefaultMavenPluginExecutor.java149
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/DatabaseLessPhaseExecutor.java17
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/DatabaseModePhaseExecutor.java16
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/InitializersExecutor.java23
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/MavenPhaseEvent.java41
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/Phases.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java21
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java27
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java12
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java9
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/maven/FakeMavenPluginExecutor.java38
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPluginExecutor.java33
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPluginsConfigurator.java74
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/maven/package-info.java23
17 files changed, 11 insertions, 510 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java
index c1801298afc..ea8dac835fb 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java
@@ -27,7 +27,6 @@ import org.sonar.batch.design.MavenDependenciesSensor;
import org.sonar.batch.design.ProjectDsmDecorator;
import org.sonar.batch.design.SubProjectDsmDecorator;
import org.sonar.batch.issue.tracking.IssueTracking;
-import org.sonar.batch.maven.DefaultMavenPluginExecutor;
import org.sonar.batch.maven.MavenProjectBootstrapper;
import org.sonar.batch.maven.MavenProjectBuilder;
import org.sonar.batch.maven.MavenProjectConverter;
@@ -57,7 +56,7 @@ public class BatchComponents {
public static Collection all(DefaultAnalysisMode analysisMode) {
List components = Lists.newArrayList(
// Maven
- MavenProjectBootstrapper.class, DefaultMavenPluginExecutor.class, MavenProjectConverter.class, MavenProjectBuilder.class,
+ MavenProjectBootstrapper.class, MavenProjectConverter.class, MavenProjectBuilder.class,
// Design
ProjectDsmDecorator.class,
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java
index b9e3dd0a960..95f333fe93e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java
@@ -28,8 +28,6 @@ import org.sonar.api.batch.CheckProject;
import org.sonar.api.batch.DependedUpon;
import org.sonar.api.batch.DependsUpon;
import org.sonar.api.batch.Phase;
-import org.sonar.api.batch.maven.DependsUponMavenPlugin;
-import org.sonar.api.batch.maven.MavenPluginHandler;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.platform.ComponentContainer;
@@ -74,29 +72,6 @@ public class BatchExtensionDictionnary {
return result;
}
- public Collection<MavenPluginHandler> selectMavenPluginHandlers(Project project) {
- List<DependsUponMavenPlugin> selectedExtensions = Lists.newArrayList();
- for (Object extension : getExtensions(null)) {
- if (ClassUtils.isAssignable(extension.getClass(), DependsUponMavenPlugin.class)) {
- selectedExtensions.add((DependsUponMavenPlugin) extension);
- }
- }
- List<MavenPluginHandler> handlers = Lists.newArrayList();
- for (DependsUponMavenPlugin extension : selectedExtensions) {
- MavenPluginHandler handler = extension.getMavenPluginHandler(project);
- if (handler != null) {
- boolean ok = true;
- if (handler instanceof CheckProject) {
- ok = ((CheckProject) handler).shouldExecuteOnProject(project);
- }
- if (ok) {
- handlers.add(handler);
- }
- }
- }
- return handlers;
- }
-
private Phase.Name evaluatePhase(Object extension) {
Object extensionToEvaluate;
if (extension instanceof SensorWrapper) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/maven/DefaultMavenPluginExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/maven/DefaultMavenPluginExecutor.java
deleted file mode 100644
index fb0a1a56a20..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/maven/DefaultMavenPluginExecutor.java
+++ /dev/null
@@ -1,149 +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.maven;
-
-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.api.batch.SupportedEnvironment;
-import org.sonar.api.batch.maven.MavenPlugin;
-import org.sonar.api.batch.maven.MavenPluginHandler;
-import org.sonar.api.resources.Project;
-import org.sonar.api.utils.SonarException;
-import org.sonar.api.utils.TimeProfiler;
-import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
-import org.sonar.batch.scan.maven.MavenPluginExecutor;
-
-import javax.annotation.Nullable;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-@SupportedEnvironment("maven")
-public class DefaultMavenPluginExecutor implements MavenPluginExecutor {
-
- private final MavenProjectConverter pomConverter;
- private LifecycleExecutor lifecycleExecutor;
- private MavenSession mavenSession;
-
- public DefaultMavenPluginExecutor(LifecycleExecutor le, MavenSession mavenSession, MavenProjectConverter pomConverter) {
- this.lifecycleExecutor = le;
- this.mavenSession = mavenSession;
- this.pomConverter = pomConverter;
- }
-
- @Override
- public final MavenPluginHandler execute(Project project, DefaultModuleFileSystem fs, MavenPluginHandler handler) {
- for (String goal : handler.getGoals()) {
- if (goal == null) {
- throw new IllegalStateException("Maven goal can't be null");
- }
- MavenPlugin plugin = MavenPlugin.getPlugin(project.getPom(), handler.getGroupId(), handler.getArtifactId());
- execute(project,
- fs,
- getGoal(handler.getGroupId(), handler.getArtifactId(), plugin != null && plugin.getPlugin() != null ? plugin.getPlugin().getVersion() : null, goal));
- }
- return handler;
- }
-
- @Override
- public final void execute(Project project, DefaultModuleFileSystem fs, String goal) {
- if (project.getPom() != null) {
- TimeProfiler profiler = new TimeProfiler().start("Execute " + goal);
- ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- concreteExecute(project.getPom(), goal);
- } catch (Exception e) {
- throw new SonarException("Unable to execute maven plugin", e);
- } finally {
- // Reset original ClassLoader that may have been changed during Maven Execution (see SONAR-1800)
- Thread.currentThread().setContextClassLoader(currentClassLoader);
- profiler.stop();
- }
- if (!fs.isInitialized()) {
- pomConverter.synchronizeFileSystem(project.getPom(), fs);
- }
- }
- }
-
- static String getGoal(String groupId, String artifactId, @Nullable String version, String goal) {
- String defaultVersion = version == null ? "" : version;
- return new StringBuilder()
- .append(groupId).append(":")
- .append(artifactId).append(":")
- .append(defaultVersion)
- .append(":")
- .append(goal)
- .toString();
- }
-
- public void concreteExecute(MavenProject pom, String goal) {
- Method executeMethod = null;
- for (Method m : lifecycleExecutor.getClass().getMethods()) {
- if ("execute".equals(m.getName())) {
- executeMethod = m;
- break;
- }
- }
- if (executeMethod == null) {
- throw new SonarException("Unable to find execute method on Maven LifecycleExecutor. Please check your Maven version.");
- }
- if (executeMethod.getParameterTypes().length == 1) {
- concreteExecuteMaven3(pom, goal);
- } else if (executeMethod.getParameterTypes().length == 3) {
- concreteExecuteMaven2(executeMethod, pom, goal);
- } else {
- throw new SonarException("Unexpected parameter count on Maven LifecycleExecutor#execute method. Please check your Maven version.");
- }
- }
-
- public void concreteExecuteMaven3(MavenProject pom, String goal) {
- MavenSession projectSession = mavenSession.clone();
- projectSession.setCurrentProject(pom);
- projectSession.setProjects(Arrays.asList(pom));
- projectSession.getRequest().setRecursive(false);
- projectSession.getRequest().setPom(pom.getFile());
- projectSession.getRequest().setGoals(Arrays.asList(goal));
- projectSession.getRequest().setInteractiveMode(false);
- lifecycleExecutor.execute(projectSession);
- if (projectSession.getResult().hasExceptions()) {
- throw new SonarException("Exception during execution of " + goal);
- }
- }
-
- public void concreteExecuteMaven2(Method executeMethod, MavenProject pom, String goal) {
- try {
- 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());
- executeMethod.invoke(lifecycleExecutor, clonedSession, reactor, clonedSession.getEventDispatcher());
- } catch (Exception e) {
- throw new SonarException("Unable to execute Maven 2 plugin", e);
- }
- }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/DatabaseLessPhaseExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/DatabaseLessPhaseExecutor.java
index 9ab360e7f44..f53ce1b715e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/DatabaseLessPhaseExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/DatabaseLessPhaseExecutor.java
@@ -30,14 +30,12 @@ import org.sonar.batch.report.PublishReportJob;
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.MavenPluginsConfigurator;
import org.sonar.batch.scan.report.IssuesReports;
public final class DatabaseLessPhaseExecutor implements PhaseExecutor {
private final EventBus eventBus;
private final Phases phases;
- private final MavenPluginsConfigurator mavenPluginsConfigurator;
private final InitializersExecutor initializersExecutor;
private final SensorsExecutor sensorsExecutor;
private final SensorContext sensorContext;
@@ -51,14 +49,11 @@ public final class DatabaseLessPhaseExecutor implements PhaseExecutor {
private final LocalIssueTracking localIssueTracking;
private final PublishReportJob publishReportJob;
- public DatabaseLessPhaseExecutor(Phases phases,
- MavenPluginsConfigurator mavenPluginsConfigurator, InitializersExecutor initializersExecutor,
- SensorsExecutor sensorsExecutor,
+ public DatabaseLessPhaseExecutor(Phases phases, InitializersExecutor initializersExecutor, SensorsExecutor sensorsExecutor,
SensorContext sensorContext, DefaultIndex index,
EventBus eventBus, ProjectInitializer pi, FileSystemLogger fsLogger, IssuesReports jsonReport, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier,
IssueExclusionsLoader issueExclusionsLoader, LocalIssueTracking localIssueTracking, PublishReportJob publishReportJob) {
this.phases = phases;
- this.mavenPluginsConfigurator = mavenPluginsConfigurator;
this.initializersExecutor = initializersExecutor;
this.sensorsExecutor = sensorsExecutor;
this.sensorContext = sensorContext;
@@ -83,8 +78,6 @@ public final class DatabaseLessPhaseExecutor implements PhaseExecutor {
eventBus.fireEvent(new ProjectAnalysisEvent(module, true));
- executeMavenPhase(module);
-
executeInitializersPhase();
if (phases.isEnabled(Phases.Phase.SENSOR)) {
@@ -152,14 +145,6 @@ public final class DatabaseLessPhaseExecutor implements PhaseExecutor {
}
}
- private void executeMavenPhase(Project module) {
- if (phases.isEnabled(Phases.Phase.MAVEN)) {
- eventBus.fireEvent(new MavenPhaseEvent(true));
- mavenPluginsConfigurator.execute(module);
- eventBus.fireEvent(new MavenPhaseEvent(false));
- }
- }
-
private void cleanMemory() {
String cleanMemory = "Clean memory";
eventBus.fireEvent(new BatchStepEvent(cleanMemory, true));
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/DatabaseModePhaseExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/DatabaseModePhaseExecutor.java
index e4e8443dd05..cf54bb43943 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/DatabaseModePhaseExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/DatabaseModePhaseExecutor.java
@@ -35,7 +35,6 @@ import org.sonar.batch.report.PublishReportJob;
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.MavenPluginsConfigurator;
import org.sonar.batch.scan.report.IssuesReports;
import java.util.ArrayList;
@@ -51,7 +50,6 @@ public final class DatabaseModePhaseExecutor implements PhaseExecutor {
private final EventBus eventBus;
private final Phases phases;
private final DecoratorsExecutor decoratorsExecutor;
- private final MavenPluginsConfigurator mavenPluginsConfigurator;
private final PostJobsExecutor postJobsExecutor;
private final InitializersExecutor initializersExecutor;
private final SensorsExecutor sensorsExecutor;
@@ -70,15 +68,13 @@ public final class DatabaseModePhaseExecutor implements PhaseExecutor {
private final ResourcePersister resourcePersister;
public DatabaseModePhaseExecutor(Phases phases, DecoratorsExecutor decoratorsExecutor,
- MavenPluginsConfigurator mavenPluginsConfigurator, InitializersExecutor initializersExecutor,
- PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor,
+ InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor,
SensorContext sensorContext, DefaultIndex index,
EventBus eventBus, PublishReportJob publishReportJob, ProjectInitializer pi,
ScanPersister[] persisters, FileSystemLogger fsLogger, IssuesReports jsonReport, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier,
IssueExclusionsLoader issueExclusionsLoader, DefaultAnalysisMode analysisMode, DatabaseSession session, ResourcePersister resourcePersister) {
this.phases = phases;
this.decoratorsExecutor = decoratorsExecutor;
- this.mavenPluginsConfigurator = mavenPluginsConfigurator;
this.postJobsExecutor = postJobsExecutor;
this.initializersExecutor = initializersExecutor;
this.sensorsExecutor = sensorsExecutor;
@@ -107,8 +103,6 @@ public final class DatabaseModePhaseExecutor implements PhaseExecutor {
eventBus.fireEvent(new ProjectAnalysisEvent(module, true));
- executeMavenPhase(module);
-
executeInitializersPhase();
if (phases.isEnabled(Phases.Phase.SENSOR)) {
@@ -202,14 +196,6 @@ public final class DatabaseModePhaseExecutor implements PhaseExecutor {
}
}
- private void executeMavenPhase(Project module) {
- if (phases.isEnabled(Phases.Phase.MAVEN)) {
- eventBus.fireEvent(new MavenPhaseEvent(true));
- mavenPluginsConfigurator.execute(module);
- eventBus.fireEvent(new MavenPhaseEvent(false));
- }
- }
-
private void cleanMemory() {
String cleanMemory = "Clean memory";
eventBus.fireEvent(new BatchStepEvent(cleanMemory, true));
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersExecutor.java
index a869dfb6ddd..b6d1de32299 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersExecutor.java
@@ -24,14 +24,10 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.Initializer;
-import org.sonar.api.batch.maven.DependsUponMavenPlugin;
-import org.sonar.api.batch.maven.MavenPluginHandler;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.TimeProfiler;
import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
import org.sonar.batch.events.EventBus;
-import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
-import org.sonar.batch.scan.maven.MavenPluginExecutor;
import java.util.Collection;
@@ -39,18 +35,13 @@ public class InitializersExecutor {
private static final Logger LOG = LoggerFactory.getLogger(SensorsExecutor.class);
- private MavenPluginExecutor mavenExecutor;
-
- private DefaultModuleFileSystem fs;
private Project project;
private BatchExtensionDictionnary selector;
private EventBus eventBus;
- public InitializersExecutor(BatchExtensionDictionnary selector, Project project, DefaultModuleFileSystem fs, MavenPluginExecutor mavenExecutor, EventBus eventBus) {
+ public InitializersExecutor(BatchExtensionDictionnary selector, Project project, EventBus eventBus) {
this.selector = selector;
- this.mavenExecutor = mavenExecutor;
this.project = project;
- this.fs = fs;
this.eventBus = eventBus;
}
@@ -63,7 +54,6 @@ public class InitializersExecutor {
for (Initializer initializer : initializers) {
eventBus.fireEvent(new InitializerExecutionEvent(initializer, true));
- executeMavenPlugin(initializer);
TimeProfiler profiler = new TimeProfiler(LOG).start("Initializer " + initializer);
initializer.execute(project);
@@ -74,15 +64,4 @@ public class InitializersExecutor {
eventBus.fireEvent(new InitializersPhaseEvent(Lists.newArrayList(initializers), false));
}
- private void executeMavenPlugin(Initializer sensor) {
- if (sensor instanceof DependsUponMavenPlugin) {
- MavenPluginHandler handler = ((DependsUponMavenPlugin) sensor).getMavenPluginHandler(project);
- if (handler != null) {
- TimeProfiler profiler = new TimeProfiler(LOG).start("Execute maven plugin " + handler.getArtifactId());
- mavenExecutor.execute(project, fs, handler);
- profiler.stop();
- }
- }
- }
-
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/MavenPhaseEvent.java b/sonar-batch/src/main/java/org/sonar/batch/phases/MavenPhaseEvent.java
deleted file mode 100644
index 43919770d75..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/MavenPhaseEvent.java
+++ /dev/null
@@ -1,41 +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.phases;
-
-import org.sonar.api.batch.events.MavenPhaseHandler;
-
-class MavenPhaseEvent extends AbstractPhaseEvent<MavenPhaseHandler>
- implements org.sonar.api.batch.events.MavenPhaseHandler.MavenPhaseEvent {
-
- MavenPhaseEvent(boolean start) {
- super(start);
- }
-
- @Override
- protected void dispatch(MavenPhaseHandler handler) {
- handler.onMavenPhase(this);
- }
-
- @Override
- protected Class getType() {
- return MavenPhaseHandler.class;
- }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/Phases.java b/sonar-batch/src/main/java/org/sonar/batch/phases/Phases.java
index 4ce24c70a6b..6c84c6dff15 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/Phases.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/Phases.java
@@ -27,7 +27,7 @@ import java.util.Set;
public class Phases {
public static enum Phase {
- MAVEN("Maven"), INIT("Initializers"), SENSOR("Sensors"), DECORATOR("Decorators"), PERSISTER("Persisters"), POSTJOB("Post-Jobs");
+ INIT("Initializers"), SENSOR("Sensors"), DECORATOR("Decorators"), PERSISTER("Persisters"), POSTJOB("Post-Jobs");
private final String label;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java
index a3ac8027737..801a9f3447a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java
@@ -26,13 +26,9 @@ import org.slf4j.LoggerFactory;
import org.sonar.api.BatchComponent;
import org.sonar.api.batch.PostJob;
import org.sonar.api.batch.SensorContext;
-import org.sonar.api.batch.maven.DependsUponMavenPlugin;
-import org.sonar.api.batch.maven.MavenPluginHandler;
import org.sonar.api.resources.Project;
import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
import org.sonar.batch.events.EventBus;
-import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
-import org.sonar.batch.scan.maven.MavenPluginExecutor;
import java.util.Collection;
@@ -41,16 +37,11 @@ public class PostJobsExecutor implements BatchComponent {
private final BatchExtensionDictionnary selector;
private final Project project;
- private final DefaultModuleFileSystem fs;
- private final MavenPluginExecutor mavenExecutor;
private final EventBus eventBus;
- public PostJobsExecutor(BatchExtensionDictionnary selector, Project project, DefaultModuleFileSystem fs, MavenPluginExecutor mavenExecutor,
- EventBus eventBus) {
+ public PostJobsExecutor(BatchExtensionDictionnary selector, Project project, EventBus eventBus) {
this.selector = selector;
this.project = project;
- this.fs = fs;
- this.mavenExecutor = mavenExecutor;
this.eventBus = eventBus;
}
@@ -68,7 +59,6 @@ public class PostJobsExecutor implements BatchComponent {
for (PostJob postJob : postJobs) {
LOG.info("Executing post-job {}", postJob.getClass());
eventBus.fireEvent(new PostJobExecutionEvent(postJob, true));
- executeMavenPlugin(postJob);
postJob.executeOn(project, context);
eventBus.fireEvent(new PostJobExecutionEvent(postJob, false));
}
@@ -79,13 +69,4 @@ public class PostJobsExecutor implements BatchComponent {
LOG.debug("Post-jobs : {}", StringUtils.join(postJobs, " -> "));
}
}
-
- private void executeMavenPlugin(PostJob job) {
- if (job instanceof DependsUponMavenPlugin) {
- MavenPluginHandler handler = ((DependsUponMavenPlugin) job).getMavenPluginHandler(project);
- if (handler != null) {
- mavenExecutor.execute(project, fs, handler);
- }
- }
- }
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java
index 5438ad76408..0c4b08160e3 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java
@@ -20,39 +20,26 @@
package org.sonar.batch.phases;
import com.google.common.collect.Lists;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.sonar.api.BatchComponent;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
-import org.sonar.api.batch.maven.DependsUponMavenPlugin;
-import org.sonar.api.batch.maven.MavenPluginHandler;
import org.sonar.api.resources.Project;
-import org.sonar.api.utils.TimeProfiler;
import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
import org.sonar.batch.events.EventBus;
-import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
-import org.sonar.batch.scan.maven.MavenPluginExecutor;
import java.util.Collection;
public class SensorsExecutor implements BatchComponent {
- private static final Logger LOG = LoggerFactory.getLogger(SensorsExecutor.class);
- private MavenPluginExecutor mavenExecutor;
private EventBus eventBus;
private Project module;
- private DefaultModuleFileSystem fs;
private BatchExtensionDictionnary selector;
private final SensorMatcher sensorMatcher;
- public SensorsExecutor(BatchExtensionDictionnary selector, Project project, DefaultModuleFileSystem fs, MavenPluginExecutor mavenExecutor, EventBus eventBus,
- SensorMatcher sensorMatcher) {
+ public SensorsExecutor(BatchExtensionDictionnary selector, Project project, EventBus eventBus, SensorMatcher sensorMatcher) {
this.selector = selector;
- this.mavenExecutor = mavenExecutor;
this.eventBus = eventBus;
this.module = project;
- this.fs = fs;
this.sensorMatcher = sensorMatcher;
}
@@ -69,19 +56,7 @@ public class SensorsExecutor implements BatchComponent {
private void executeSensor(SensorContext context, Sensor sensor) {
eventBus.fireEvent(new SensorExecutionEvent(sensor, true));
- executeMavenPlugin(sensor);
sensor.analyse(module, context);
eventBus.fireEvent(new SensorExecutionEvent(sensor, false));
}
-
- private void executeMavenPlugin(Sensor sensor) {
- if (sensor instanceof DependsUponMavenPlugin) {
- MavenPluginHandler handler = ((DependsUponMavenPlugin) sensor).getMavenPluginHandler(module);
- if (handler != null) {
- TimeProfiler profiler = new TimeProfiler(LOG).start("Execute maven plugin " + handler.getArtifactId());
- mavenExecutor.execute(module, fs, handler);
- profiler.stop();
- }
- }
- }
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java
index 06bd41dabe1..30956a0a263 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java
@@ -30,7 +30,6 @@ import org.sonar.api.batch.events.DecoratorExecutionHandler;
import org.sonar.api.batch.events.DecoratorsPhaseHandler;
import org.sonar.api.batch.events.InitializerExecutionHandler;
import org.sonar.api.batch.events.InitializersPhaseHandler;
-import org.sonar.api.batch.events.MavenPhaseHandler;
import org.sonar.api.batch.events.PostJobExecutionHandler;
import org.sonar.api.batch.events.PostJobsPhaseHandler;
import org.sonar.api.batch.events.ProjectAnalysisHandler;
@@ -59,7 +58,7 @@ import static org.sonar.batch.profiling.AbstractTimeProfiling.sortByDescendingTo
import static org.sonar.batch.profiling.AbstractTimeProfiling.truncate;
public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorExecutionHandler, DecoratorExecutionHandler, PostJobExecutionHandler, DecoratorsPhaseHandler,
- SensorsPhaseHandler, PostJobsPhaseHandler, MavenPhaseHandler, InitializersPhaseHandler, InitializerExecutionHandler, BatchStepHandler, PersistersPhaseHandler,
+ SensorsPhaseHandler, PostJobsPhaseHandler, InitializersPhaseHandler, InitializerExecutionHandler, BatchStepHandler, PersistersPhaseHandler,
PersisterExecutionHandler {
static final Logger LOG = LoggerFactory.getLogger(PhasesSumUpTimeProfiler.class);
@@ -242,15 +241,6 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx
}
@Override
- public void onMavenPhase(MavenPhaseEvent event) {
- if (event.isStart()) {
- currentModuleProfiling.addPhaseProfiling(Phases.Phase.MAVEN);
- } else {
- currentModuleProfiling.getProfilingPerPhase(Phases.Phase.MAVEN).stop();
- }
- }
-
- @Override
public void onInitializersPhase(InitializersPhaseEvent event) {
if (event.isStart()) {
currentModuleProfiling.addPhaseProfiling(Phases.Phase.INIT);
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 1bbd1915a19..e350fd28992 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
@@ -34,8 +34,8 @@ import org.sonar.batch.DefaultTimeMachine;
import org.sonar.batch.DeprecatedSensorContext;
import org.sonar.batch.ProjectTree;
import org.sonar.batch.ResourceFilters;
-import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
+import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.ExtensionInstaller;
import org.sonar.batch.bootstrap.ExtensionMatcher;
import org.sonar.batch.bootstrap.ExtensionUtils;
@@ -60,13 +60,13 @@ import org.sonar.batch.issue.tracking.InitialOpenIssuesSensor;
import org.sonar.batch.issue.tracking.IssueHandlers;
import org.sonar.batch.issue.tracking.IssueTrackingDecorator;
import org.sonar.batch.language.LanguageDistributionDecorator;
-import org.sonar.batch.phases.DecoratorsExecutor;
+import org.sonar.batch.phases.DatabaseLessPhaseExecutor;
import org.sonar.batch.phases.DatabaseModePhaseExecutor;
+import org.sonar.batch.phases.DecoratorsExecutor;
import org.sonar.batch.phases.InitializersExecutor;
import org.sonar.batch.phases.PhaseExecutor;
import org.sonar.batch.phases.PhasesTimeProfiler;
import org.sonar.batch.phases.PostJobsExecutor;
-import org.sonar.batch.phases.DatabaseLessPhaseExecutor;
import org.sonar.batch.phases.ProjectInitializer;
import org.sonar.batch.phases.SensorsExecutor;
import org.sonar.batch.qualitygate.GenerateQualityGateEvents;
@@ -94,7 +94,6 @@ import org.sonar.batch.scan.filesystem.ModuleFileSystemInitializer;
import org.sonar.batch.scan.filesystem.ModuleInputFileCache;
import org.sonar.batch.scan.filesystem.ProjectFileSystemAdapter;
import org.sonar.batch.scan.filesystem.StatusDetectionFactory;
-import org.sonar.batch.scan.maven.MavenPluginsConfigurator;
import org.sonar.batch.scan.report.IssuesReports;
import org.sonar.batch.sensor.AnalyzerOptimizer;
import org.sonar.batch.sensor.DefaultSensorContext;
@@ -144,7 +143,6 @@ public class ModuleScanContainer extends ComponentContainer {
add(
EventBus.class,
PhasesTimeProfiler.class,
- MavenPluginsConfigurator.class,
PostJobsExecutor.class,
SensorsExecutor.class,
InitializersExecutor.class,
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
index 7a76e684ae7..df9a85a1d85 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
@@ -70,8 +70,6 @@ import org.sonar.batch.repository.ProjectRepositoriesProvider;
import org.sonar.batch.rule.ActiveRulesProvider;
import org.sonar.batch.rule.RulesProvider;
import org.sonar.batch.scan.filesystem.InputPathCache;
-import org.sonar.batch.scan.maven.FakeMavenPluginExecutor;
-import org.sonar.batch.scan.maven.MavenPluginExecutor;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.batch.source.CodeColorizers;
import org.sonar.batch.source.HighlightableBuilder;
@@ -104,7 +102,6 @@ public class ProjectScanContainer extends ComponentContainer {
if (analysisMode.isDb()) {
addDataBaseComponents();
}
- fixMavenExecutor();
addBatchExtensions();
Settings settings = getComponentByType(Settings.class);
if (settings != null && settings.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY)) {
@@ -223,12 +220,6 @@ public class ProjectScanContainer extends ComponentContainer {
ProjectLock.class);
}
- private void fixMavenExecutor() {
- if (getComponentByType(MavenPluginExecutor.class) == null) {
- add(FakeMavenPluginExecutor.class);
- }
- }
-
private void addBatchExtensions() {
getComponentByType(ExtensionInstaller.class).install(this, new BatchExtensionFilter());
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/maven/FakeMavenPluginExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/scan/maven/FakeMavenPluginExecutor.java
deleted file mode 100644
index 180549435e3..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/maven/FakeMavenPluginExecutor.java
+++ /dev/null
@@ -1,38 +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.sonar.api.batch.maven.MavenPluginHandler;
-import org.sonar.api.resources.Project;
-import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
-
-public final class FakeMavenPluginExecutor implements MavenPluginExecutor {
-
- @Override
- public void execute(Project project, DefaultModuleFileSystem fs, String goal) {
- // do nothing
- }
-
- @Override
- public MavenPluginHandler execute(Project project, DefaultModuleFileSystem fs, MavenPluginHandler handler) {
- // do nothing
- return handler;
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPluginExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPluginExecutor.java
deleted file mode 100644
index e86c2a4dceb..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPluginExecutor.java
+++ /dev/null
@@ -1,33 +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.sonar.api.batch.maven.MavenPluginHandler;
-import org.sonar.api.resources.Project;
-import org.sonar.api.task.TaskExtension;
-import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
-
-public interface MavenPluginExecutor extends TaskExtension {
-
- void execute(Project project, DefaultModuleFileSystem def, String goal);
-
- MavenPluginHandler execute(Project project, DefaultModuleFileSystem def, MavenPluginHandler handler);
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPluginsConfigurator.java b/sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPluginsConfigurator.java
deleted file mode 100644
index 010545a709c..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/maven/MavenPluginsConfigurator.java
+++ /dev/null
@@ -1,74 +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.apache.commons.io.Charsets;
-import org.apache.maven.project.MavenProject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
-import org.sonar.api.batch.maven.MavenPlugin;
-import org.sonar.api.batch.maven.MavenPluginHandler;
-import org.sonar.api.resources.Project;
-import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-
-public class MavenPluginsConfigurator implements BatchComponent {
-
- private BatchExtensionDictionnary dictionnary = null;
-
- public MavenPluginsConfigurator(BatchExtensionDictionnary dictionnary) {
- this.dictionnary = dictionnary;
- }
-
- public void execute(Project project) {
- Logger logger = LoggerFactory.getLogger(getClass());
- logger.info("Configure Maven plugins");
-
- for (MavenPluginHandler handler : dictionnary.selectMavenPluginHandlers(project)) {
- logger.debug("Configure {}...", handler);
- configureHandler(project, handler);
- }
- savePom(project);
- }
-
- protected void configureHandler(Project project, MavenPluginHandler handler) {
- MavenPlugin plugin = MavenPlugin.registerPlugin(project.getPom(), handler.getGroupId(), handler.getArtifactId(), handler.getVersion(), handler.isFixedVersion());
- handler.configure(project, plugin);
- }
-
- protected void savePom(Project project) {
- MavenProject pom = project.getPom();
- if (pom != null) {
- File targetPom = new File(project.getFileSystem().getSonarWorkingDirectory(), "sonar-pom.xml");
- try (Writer fileWriter = new OutputStreamWriter(new FileOutputStream(targetPom, false), Charsets.UTF_8)) {
- pom.writeModel(fileWriter);
-
- } catch (IOException e) {
- throw new IllegalStateException("Can not save pom to " + targetPom, e);
- }
- }
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/maven/package-info.java b/sonar-batch/src/main/java/org/sonar/batch/scan/maven/package-info.java
deleted file mode 100644
index e8443364ac6..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/maven/package-info.java
+++ /dev/null
@@ -1,23 +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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.batch.scan.maven;
-
-import javax.annotation.ParametersAreNonnullByDefault;