aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/main/java/org/sonar/batch/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch/bootstrap')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectExtensionInstaller.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java11
4 files changed, 19 insertions, 12 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java
index fc9c344412a..10546623f32 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java
@@ -21,6 +21,7 @@ package org.sonar.batch.bootstrap;
import org.apache.commons.configuration.Configuration;
import org.sonar.api.Plugin;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.utils.HttpDownloader;
import org.sonar.batch.FakeMavenPluginExecutor;
import org.sonar.batch.MavenPluginExecutor;
@@ -39,14 +40,17 @@ public class BootstrapModule extends Module {
private Configuration configuration;
private Object[] boostrapperComponents;
+ private ProjectReactor reactor;
- public BootstrapModule(Configuration configuration, Object... boostrapperComponents) {
+ public BootstrapModule(ProjectReactor reactor, Configuration configuration, Object... boostrapperComponents) {
+ this.reactor = reactor;
this.configuration = configuration;
this.boostrapperComponents = boostrapperComponents;
}
@Override
protected void configure() {
+ addComponent(reactor);
addComponent(configuration);
addComponent(ServerMetadata.class);// registered here because used by BootstrapClassLoader
addComponent(TempDirectories.class);// registered here because used by BootstrapClassLoader
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java
index a7907b6b08e..6214d8d4e53 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java
@@ -60,6 +60,12 @@ public final class ExtensionUtils {
return false;
}
+ static boolean isMavenExtensionOnly(Object extension) {
+ Class clazz = (extension instanceof Class ? (Class) extension : extension.getClass());
+ SupportedEnvironment env = AnnotationUtils.getClassAnnotation(clazz, SupportedEnvironment.class);
+ return env!=null && env.value().length==1 && StringUtils.equalsIgnoreCase("maven", env.value()[0]);
+ }
+
static boolean isType(Object extension, Class<? extends Extension> extensionClass) {
Class clazz = (extension instanceof Class ? (Class) extension : extension.getClass());
return extensionClass.isAssignableFrom(clazz);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectExtensionInstaller.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectExtensionInstaller.java
index bfb924cf7b4..49debff0d19 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectExtensionInstaller.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectExtensionInstaller.java
@@ -50,7 +50,6 @@ public final class ProjectExtensionInstaller implements BatchComponent {
installExtension(module, extension, project, entry.getKey());
}
}
-
installExtensionProviders(module, project);
}
@@ -72,7 +71,8 @@ public final class ProjectExtensionInstaller implements BatchComponent {
if (ExtensionUtils.isBatchExtension(extension) &&
ExtensionUtils.isSupportedEnvironment(extension, environment) &&
ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_PROJECT) &&
- !isDeactivatedCoverageExtension(extension, project, pluginKey)) {
+ !isDeactivatedCoverageExtension(extension, project, pluginKey) &&
+ !isMavenExtensionOnEmulatedMavenProject(extension, project)) {
module.addComponent(extension);
return extension;
@@ -80,6 +80,10 @@ public final class ProjectExtensionInstaller implements BatchComponent {
return null;
}
+ boolean isMavenExtensionOnEmulatedMavenProject(Object extension, Project project) {
+ return ExtensionUtils.isMavenExtensionOnly(extension) && project.getPom() == null;
+ }
+
/**
* TODO this code is specific to Java projects and should be moved somewhere else
*/
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java
index 26c3609cbaf..7f1827a9808 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java
@@ -19,10 +19,10 @@
*/
package org.sonar.batch.bootstrap;
-import org.apache.maven.project.MavenProject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.BatchExtensionDictionnary;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Metric;
import org.sonar.api.measures.Metrics;
@@ -34,7 +34,6 @@ import org.sonar.api.resources.ProjectFileSystem;
import org.sonar.api.rules.DefaultRulesManager;
import org.sonar.api.utils.SonarException;
import org.sonar.batch.*;
-import org.sonar.batch.bootstrapper.ProjectDefinition;
import org.sonar.batch.components.PastViolationsLoader;
import org.sonar.batch.components.TimeMachineConfiguration;
import org.sonar.batch.events.EventBus;
@@ -69,18 +68,12 @@ public class ProjectModule extends Module {
addComponent(projectDefinition);
for (Object component : projectDefinition.getContainerExtensions()) {
addComponent(component);
- if (component instanceof MavenProject) {
- // For backward compatibility we must set POM and actual packaging
- MavenProject pom = (MavenProject) component;
- project.setPom(pom);
- project.setPackaging(pom.getPackaging());
- }
}
addComponent(project);
+ addComponent(project.getConfiguration());
addComponent(DefaultProjectClasspath.class);
addComponent(DefaultProjectFileSystem2.class);
- addComponent(project.getConfiguration());
addComponent(DaoFacade.class);
addComponent(RulesDao.class);