aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-05-11 12:09:44 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-05-11 17:04:46 +0200
commitecbaff37b60045b8ba4cbc127633fde73b2bb1cb (patch)
treeef15e4d9c7da5691e63ad9ea15d6310b2ef0b676
parent3c18d94e800d30e71b2ca578b2a4d606f824e844 (diff)
downloadsonarqube-ecbaff37b60045b8ba4cbc127633fde73b2bb1cb.tar.gz
sonarqube-ecbaff37b60045b8ba4cbc127633fde73b2bb1cb.zip
SONAR-6536 Drop concept of task
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/DefaultProjectTree.java20
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java35
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/AnalysisProperties.java (renamed from sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskProperties.java)6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java121
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/ListTask.java59
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/Tasks.java74
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/package-info.java23
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java26
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java14
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/IssuableFactory.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesLoader.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilder.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ImmutableProjectReactor.java70
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ImmutableProjectReactorProvider.java (renamed from sonar-batch/src/test/java/org/sonar/batch/scan/ScanTaskTest.java)24
-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/MutableProjectReactorProvider.java56
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectBuildersExecutor.java56
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java18
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectLock.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java72
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java72
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java56
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java24
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskContainerTest.java61
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PeriodsDefinitionTest.java18
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/deprecated/tasks/ListTaskTest.java64
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/deprecated/tasks/TasksTest.java92
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java12
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java12
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/IssuableFactoryTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java11
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java24
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectLockTest.java14
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java12
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorReadyTest.java42
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java69
-rw-r--r--sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a1/.sonar/sonar-report.json1
-rw-r--r--sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo16
-rw-r--r--sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo12
-rw-r--r--sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo12
-rw-r--r--sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo12
-rw-r--r--sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties31
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectBootstrapper.java7
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectReactor.java1
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/events/EventHandler.java2
57 files changed, 511 insertions, 936 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectTree.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectTree.java
index 1d9aeed130f..343ecb787ed 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectTree.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectTree.java
@@ -22,33 +22,37 @@ package org.sonar.batch;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang.ObjectUtils;
+import org.picocontainer.Startable;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.resources.Project;
-import org.sonar.batch.scan.ProjectReactorReady;
+import org.sonar.batch.scan.ImmutableProjectReactor;
import java.util.List;
import java.util.Map;
-public class DefaultProjectTree implements ProjectTree {
+public class DefaultProjectTree implements Startable {
private final ProjectConfigurator configurator;
- private ProjectReactor projectReactor;
+ private ImmutableProjectReactor projectReactor;
private List<Project> projects;
private Map<ProjectDefinition, Project> projectsByDef;
- public DefaultProjectTree(ProjectReactor projectReactor,
- ProjectConfigurator projectConfigurator,
- ProjectReactorReady reactorReady) {
+ public DefaultProjectTree(ImmutableProjectReactor projectReactor, ProjectConfigurator projectConfigurator) {
this.projectReactor = projectReactor;
this.configurator = projectConfigurator;
}
+ @Override
public void start() {
doStart(projectReactor.getProjects());
}
+ @Override
+ public void stop() {
+ // Nothing to do
+ }
+
void doStart(List<ProjectDefinition> definitions) {
projects = Lists.newArrayList();
projectsByDef = Maps.newHashMap();
@@ -77,7 +81,6 @@ public class DefaultProjectTree implements ProjectTree {
return projects;
}
- @Override
public Project getRootProject() {
for (Project project : projects) {
if (project.getParent() == null) {
@@ -87,7 +90,6 @@ public class DefaultProjectTree implements ProjectTree {
throw new IllegalStateException("Can not find the root project from the list of Maven modules");
}
- @Override
public ProjectDefinition getProjectDefinition(Project project) {
for (Map.Entry<ProjectDefinition, Project> entry : projectsByDef.entrySet()) {
if (ObjectUtils.equals(entry.getValue(), project)) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java
deleted file mode 100644
index eb64203f797..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java
+++ /dev/null
@@ -1,35 +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;
-
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.resources.Project;
-
-/**
- * Implemented by Views plugin.
- *
- */
-public interface ProjectTree {
-
- Project getRootProject();
-
- ProjectDefinition getProjectDefinition(Project module);
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskProperties.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/AnalysisProperties.java
index d469fcdbe05..d8b53410f60 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskProperties.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/AnalysisProperties.java
@@ -24,12 +24,12 @@ import javax.annotation.Nullable;
import java.util.Map;
/**
- * Batch properties that are specific to a task (for example
+ * Batch properties that are specific to an analysis (for example
* coming from sonar-project.properties).
*/
-public class TaskProperties extends UserProperties {
+public class AnalysisProperties extends UserProperties {
- public TaskProperties(Map<String, String> properties, @Nullable String pathToSecretKey) {
+ public AnalysisProperties(Map<String, String> properties, @Nullable String pathToSecretKey) {
super(properties, pathToSecretKey);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
index c5d2a431b8b..2b84c018c17 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
@@ -19,6 +19,7 @@
*/
package org.sonar.batch.bootstrap;
+import org.sonar.api.CoreProperties;
import org.sonar.api.Plugin;
import org.sonar.api.config.EmailSettings;
import org.sonar.api.utils.Durations;
@@ -42,6 +43,7 @@ import org.sonar.batch.repository.GlobalRepositoriesProvider;
import org.sonar.batch.repository.ProjectRepositoriesLoader;
import org.sonar.batch.repository.ServerIssuesLoader;
import org.sonar.batch.repository.user.UserRepository;
+import org.sonar.batch.scan.ProjectScanContainer;
import org.sonar.core.cluster.NullQueue;
import org.sonar.core.config.Logback;
import org.sonar.core.i18n.DefaultI18n;
@@ -170,8 +172,9 @@ public class GlobalContainer extends ComponentContainer {
}
}
- public void executeTask(Map<String, String> taskProperties, Object... components) {
- new TaskContainer(this, taskProperties, components).execute();
+ public void executeAnalysis(Map<String, String> analysisProperties, Object... components) {
+ AnalysisProperties props = new AnalysisProperties(analysisProperties, this.getComponentByType(BootstrapProperties.class).property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
+ new ProjectScanContainer(this, props, components).execute();
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java
deleted file mode 100644
index e372178e2ba..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java
+++ /dev/null
@@ -1,121 +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.bootstrap;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.CoreProperties;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.api.resources.ResourceTypes;
-import org.sonar.api.task.Task;
-import org.sonar.api.task.TaskComponent;
-import org.sonar.api.task.TaskDefinition;
-import org.sonar.api.utils.MessageException;
-import org.sonar.batch.bootstrapper.EnvironmentInformation;
-import org.sonar.batch.deprecated.tasks.ListTask;
-import org.sonar.batch.deprecated.tasks.Tasks;
-import org.sonar.batch.scan.DeprecatedProjectReactorBuilder;
-import org.sonar.batch.scan.ProjectReactorBuilder;
-import org.sonar.batch.scan.ScanTask;
-import org.sonar.core.permission.PermissionFacade;
-import org.sonar.core.resource.DefaultResourcePermissions;
-
-import java.util.Map;
-
-/**
- * Used by views !!
- */
-public class TaskContainer extends ComponentContainer {
-
- private final Map<String, String> taskProperties;
- private final Object[] components;
-
- public TaskContainer(ComponentContainer parent, Map<String, String> taskProperties, Object... components) {
- super(parent);
- this.taskProperties = taskProperties;
- this.components = components;
- }
-
- @Override
- protected void doBeforeStart() {
- installCoreTasks();
- installTaskExtensions();
- installComponentsUsingTaskExtensions();
- for (Object component : components) {
- add(component);
- }
- }
-
- void installCoreTasks() {
- add(new TaskProperties(taskProperties, getParent().getComponentByType(BootstrapProperties.class).property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH)));
- add(
- ScanTask.DEFINITION, ScanTask.class,
- ListTask.DEFINITION, ListTask.class,
- projectReactorBuilder());
- }
-
- private void installTaskExtensions() {
- getComponentByType(ExtensionInstaller.class).install(this, new ExtensionMatcher() {
- @Override
- public boolean accept(Object extension) {
- return ExtensionUtils.isType(extension, TaskComponent.class);
- }
- });
- }
-
- private Class<?> projectReactorBuilder() {
- if (isRunnerVersionLessThan2Dot4()) {
- return DeprecatedProjectReactorBuilder.class;
- }
- return ProjectReactorBuilder.class;
- }
-
- private boolean isRunnerVersionLessThan2Dot4() {
- EnvironmentInformation env = this.getComponentByType(EnvironmentInformation.class);
- // Starting from SQ Runner 2.4 the key is "SonarQubeRunner"
- return env != null && "SonarRunner".equals(env.getKey());
- }
-
- private void installComponentsUsingTaskExtensions() {
- add(
- ResourceTypes.class,
- PermissionFacade.class,
- DefaultResourcePermissions.class,
- Tasks.class);
- }
-
- @Override
- public void doAfterStart() {
- // default value is declared in CorePlugin
- String taskKey = StringUtils.defaultIfEmpty(taskProperties.get(CoreProperties.TASK), CoreProperties.SCAN_TASK);
- // Release memory
- taskProperties.clear();
-
- TaskDefinition def = getComponentByType(Tasks.class).definition(taskKey);
- if (def == null) {
- throw MessageException.of("Task " + taskKey + " does not exist");
- }
- Task task = getComponentByType(def.taskClass());
- if (task != null) {
- task.execute();
- } else {
- throw new IllegalStateException("Task " + taskKey + " is badly defined");
- }
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java
index 8bcae6dcc1f..70da9601bd1 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java
@@ -87,12 +87,12 @@ public final class Batch {
/**
* @since 4.4
*/
- public Batch executeTask(Map<String, String> taskProperties, Object... components) {
+ public Batch executeTask(Map<String, String> analysisProperties, Object... components) {
if (!started) {
throw new IllegalStateException("Batch is not started. Unable to execute task.");
}
- bootstrapContainer.executeTask(taskProperties, components);
+ bootstrapContainer.executeAnalysis(analysisProperties, components);
return this;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java
index 55f9b810434..dd3f8ee0826 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java
@@ -25,7 +25,7 @@ import org.sonar.api.config.Settings;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.resources.Qualifiers;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.components.PastSnapshot;
import org.sonar.batch.components.PastSnapshotFinder;
@@ -43,12 +43,12 @@ public class PeriodsDefinition {
private DatabaseSession session;
- private ProjectTree projectTree;
+ private DefaultProjectTree projectTree;
private final Settings settings;
private List<PastSnapshot> projectPastSnapshots;
- public PeriodsDefinition(DatabaseSession session, ProjectTree projectTree, Settings settings,
+ public PeriodsDefinition(DatabaseSession session, DefaultProjectTree projectTree, Settings settings,
PastSnapshotFinder pastSnapshotFinder) {
this.session = session;
this.projectTree = projectTree;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/ListTask.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/ListTask.java
deleted file mode 100644
index bcd02a00e3b..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/ListTask.java
+++ /dev/null
@@ -1,59 +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.deprecated.tasks;
-
-import org.sonar.api.task.Task;
-import org.sonar.api.task.TaskDefinition;
-
-public class ListTask implements Task {
-
- public static final String KEY = "list";
-
- public static final TaskDefinition DEFINITION = TaskDefinition.builder()
- .key(KEY)
- .description("List available tasks")
- .taskClass(ListTask.class)
- .build();
-
- private final Tasks tasks;
-
- public ListTask(Tasks tasks) {
- this.tasks = tasks;
- }
-
- @Override
- public void execute() {
- logBlankLine();
- log("Available tasks:");
- logBlankLine();
- for (TaskDefinition def : tasks.definitions()) {
- log(" - " + def.key() + ": " + def.description());
- }
- logBlankLine();
- }
-
- void log(String s) {
- System.out.println(s);
- }
-
- void logBlankLine() {
- System.out.println();
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/Tasks.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/Tasks.java
deleted file mode 100644
index c97bdea7d6a..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/Tasks.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.deprecated.tasks;
-
-import com.google.common.collect.ImmutableSortedMap;
-import com.google.common.collect.Maps;
-import org.sonar.api.task.Task;
-import org.sonar.api.task.TaskComponent;
-import org.sonar.api.task.TaskDefinition;
-import org.sonar.api.utils.SonarException;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.SortedMap;
-
-public class Tasks implements TaskComponent {
-
- private final SortedMap<String, TaskDefinition> byKey;
-
- public Tasks(TaskDefinition[] definitions) {
- SortedMap<String, TaskDefinition> map = Maps.newTreeMap();
- for (TaskDefinition definition : definitions) {
- if (map.containsKey(definition.key())) {
- throw new SonarException("Task '" + definition.key() + "' is declared twice");
- }
- map.put(definition.key(), definition);
- }
- this.byKey = ImmutableSortedMap.copyOf(map);
- }
-
- public TaskDefinition definition(String taskKey) {
- return byKey.get(taskKey);
- }
-
- public Collection<TaskDefinition> definitions() {
- return byKey.values();
- }
-
- /**
- * Perform validation of task definitions
- */
- public void start() {
- checkDuplicatedClasses();
- }
-
- private void checkDuplicatedClasses() {
- Map<Class<? extends Task>, TaskDefinition> byClass = Maps.newHashMap();
- for (TaskDefinition def : definitions()) {
- TaskDefinition other = byClass.get(def.taskClass());
- if (other == null) {
- byClass.put(def.taskClass(), def);
- } else {
- throw new SonarException("Task '" + def.taskClass().getName() + "' is defined twice: first by '" + other.key() + "' and then by '" + def.key() + "'");
- }
- }
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/package-info.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/package-info.java
deleted file mode 100644
index f346de52eb4..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/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.deprecated.tasks;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
index 3d8cdc1f72f..14803caa3b5 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
@@ -37,12 +37,18 @@ import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.measures.MeasuresFilters;
-import org.sonar.api.resources.*;
+import org.sonar.api.resources.Directory;
+import org.sonar.api.resources.File;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.Resource;
+import org.sonar.api.resources.ResourceUtils;
+import org.sonar.api.resources.Scopes;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.Violation;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.SonarException;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.issue.ModuleIssues;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.core.component.ComponentKeys;
@@ -51,7 +57,15 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
public class DefaultIndex extends SonarIndex {
@@ -90,11 +104,11 @@ public class DefaultIndex extends SonarIndex {
private Set<Dependency> dependencies = Sets.newLinkedHashSet();
private Map<Resource, Map<Resource, Dependency>> outgoingDependenciesByResource = Maps.newLinkedHashMap();
private Map<Resource, Map<Resource, Dependency>> incomingDependenciesByResource = Maps.newLinkedHashMap();
- private ProjectTree projectTree;
+ private DefaultProjectTree projectTree;
private ModuleIssues moduleIssues;
public DefaultIndex(ResourceCache resourceCache, DependencyPersister dependencyPersister,
- ProjectTree projectTree, MetricFinder metricFinder,
+ DefaultProjectTree projectTree, MetricFinder metricFinder,
ResourceKeyMigration migration, MeasureCache measureCache) {
this.resourceCache = resourceCache;
this.dependencyPersister = dependencyPersister;
@@ -104,7 +118,7 @@ public class DefaultIndex extends SonarIndex {
this.measureCache = measureCache;
}
- public DefaultIndex(ResourceCache resourceCache, DependencyPersister dependencyPersister, ProjectTree projectTree, MetricFinder metricFinder, MeasureCache measureCache) {
+ public DefaultIndex(ResourceCache resourceCache, DependencyPersister dependencyPersister, DefaultProjectTree projectTree, MetricFinder metricFinder, MeasureCache measureCache) {
this.resourceCache = resourceCache;
this.dependencyPersister = dependencyPersister;
this.projectTree = projectTree;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java
index 1520a672cc5..d76e69c6830 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java
@@ -25,11 +25,17 @@ import org.apache.commons.lang.StringUtils;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.ResourceModel;
import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.*;
+import org.sonar.api.resources.Language;
+import org.sonar.api.resources.Library;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.Resource;
+import org.sonar.api.resources.ResourceUtils;
+import org.sonar.api.resources.Scopes;
import org.sonar.api.security.ResourcePermissions;
import org.sonar.api.utils.SonarException;
import org.sonar.api.utils.internal.Uuids;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.core.component.ScanGraph;
import javax.annotation.Nullable;
@@ -54,10 +60,10 @@ public class ResourcePersister implements ScanPersister {
private final DatabaseSession session;
private final ResourcePermissions permissions;
private final ResourceCache resourceCache;
- private final ProjectTree projectTree;
+ private final DefaultProjectTree projectTree;
private final ScanGraph scanGraph;
- public ResourcePersister(ProjectTree projectTree, DatabaseSession session, ResourcePermissions permissions, ResourceCache resourceCache, ScanGraph scanGraph) {
+ public ResourcePersister(DefaultProjectTree projectTree, DatabaseSession session, ResourcePermissions permissions, ResourceCache resourceCache, ScanGraph scanGraph) {
this.projectTree = projectTree;
this.session = session;
this.permissions = permissions;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/IssuableFactory.java b/sonar-batch/src/main/java/org/sonar/batch/issue/IssuableFactory.java
index d287364b046..51ec2b9fe7e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/IssuableFactory.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/IssuableFactory.java
@@ -22,7 +22,7 @@ package org.sonar.batch.issue;
import org.sonar.api.component.Component;
import org.sonar.api.issue.Issuable;
import org.sonar.api.resources.Scopes;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.core.component.PerspectiveBuilder;
import org.sonar.core.component.ResourceComponent;
@@ -36,9 +36,9 @@ public class IssuableFactory extends PerspectiveBuilder<Issuable> {
private final ModuleIssues moduleIssues;
private final IssueCache cache;
- private final ProjectTree projectTree;
+ private final DefaultProjectTree projectTree;
- public IssuableFactory(ModuleIssues moduleIssues, IssueCache cache, ProjectTree projectTree) {
+ public IssuableFactory(ModuleIssues moduleIssues, IssueCache cache, DefaultProjectTree projectTree) {
super(Issuable.class);
this.moduleIssues = moduleIssues;
this.cache = cache;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
index 09871955a38..743c1e887bc 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
@@ -28,7 +28,7 @@ import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.batch.debt.internal.DefaultDebtModel;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Metric;
-import org.sonar.batch.bootstrap.TaskProperties;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.batch.bootstrapper.Batch;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
import org.sonar.batch.issue.tracking.ServerLineHashesLoader;
@@ -190,7 +190,6 @@ public class BatchMediumTester {
throw new IllegalStateException("Unable to read configuration file", e);
}
TaskBuilder builder = new TaskBuilder(this);
- builder.property("sonar.task", "scan");
builder.property("sonar.projectBaseDir", sonarProps.getParentFile().getAbsolutePath());
for (Map.Entry entry : prop.entrySet()) {
builder.property(entry.getKey().toString(), entry.getValue().toString());
@@ -263,7 +262,7 @@ public class BatchMediumTester {
private ProjectRepositories ref = new ProjectRepositories();
@Override
- public ProjectRepositories load(ProjectReactor reactor, TaskProperties taskProperties) {
+ public ProjectRepositories load(ProjectReactor reactor, AnalysisProperties taskProperties) {
return ref;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java b/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java
index 772f6923466..71f4953769e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java
@@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.ServerClient;
-import org.sonar.batch.bootstrap.TaskProperties;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.batch.protocol.input.ProjectRepositories;
import org.sonar.batch.rule.ModuleQProfiles;
@@ -43,7 +43,7 @@ public class DefaultProjectRepositoriesLoader implements ProjectRepositoriesLoad
}
@Override
- public ProjectRepositories load(ProjectReactor reactor, TaskProperties taskProperties) {
+ public ProjectRepositories load(ProjectReactor reactor, AnalysisProperties taskProperties) {
String projectKey = reactor.getRoot().getKeyWithBranch();
String url = BATCH_PROJECT_URL + "?key=" + ServerClient.encodeForUrl(projectKey);
if (taskProperties.properties().containsKey(ModuleQProfiles.SONAR_PROFILE_PROP)) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesLoader.java b/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesLoader.java
index 5471f1e511e..1c445fe6870 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesLoader.java
@@ -20,11 +20,11 @@
package org.sonar.batch.repository;
import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.batch.bootstrap.TaskProperties;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.batch.protocol.input.ProjectRepositories;
public interface ProjectRepositoriesLoader {
- ProjectRepositories load(ProjectReactor reactor, TaskProperties taskProperties);
+ ProjectRepositories load(ProjectReactor reactor, AnalysisProperties taskProperties);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java b/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java
index 283beec595f..6e7bbf532e5 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java
@@ -25,7 +25,7 @@ import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.utils.log.Profiler;
-import org.sonar.batch.bootstrap.TaskProperties;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.batch.protocol.input.ProjectRepositories;
public class ProjectRepositoriesProvider extends ProviderAdapter {
@@ -34,7 +34,7 @@ public class ProjectRepositoriesProvider extends ProviderAdapter {
private ProjectRepositories projectReferentials;
- public ProjectRepositories provide(ProjectRepositoriesLoader loader, ProjectReactor reactor, TaskProperties taskProps, AnalysisMode analysisMode) {
+ public ProjectRepositories provide(ProjectRepositoriesLoader loader, ProjectReactor reactor, AnalysisProperties taskProps, AnalysisMode analysisMode) {
if (projectReferentials == null) {
Profiler profiler = Profiler.create(LOG).startInfo("Load project repositories");
projectReferentials = loader.load(reactor, taskProps);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilder.java
index 6050f938d55..fd978602829 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilder.java
@@ -20,7 +20,7 @@
package org.sonar.batch.scan;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.batch.bootstrap.TaskProperties;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import java.io.File;
import java.io.IOException;
@@ -39,7 +39,7 @@ public class DeprecatedProjectReactorBuilder extends ProjectReactorBuilder {
private static final String PROPERTY_PROJECT_CONFIG_FILE = "sonar.projectConfigFile";
- public DeprecatedProjectReactorBuilder(TaskProperties props) {
+ public DeprecatedProjectReactorBuilder(AnalysisProperties props) {
super(props);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ImmutableProjectReactor.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ImmutableProjectReactor.java
new file mode 100644
index 00000000000..7eccc225565
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ImmutableProjectReactor.java
@@ -0,0 +1,70 @@
+/*
+ * 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;
+
+import org.sonar.api.BatchSide;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Immutable copy of project reactor after all modifications have been applied (see {@link MutableProjectReactorProvider}).
+ */
+@BatchSide
+public class ImmutableProjectReactor {
+
+ private ProjectDefinition root;
+
+ public ImmutableProjectReactor(ProjectDefinition root) {
+ if (root.getParent() != null) {
+ throw new IllegalArgumentException("Not a root project: " + root);
+ }
+ this.root = root;
+ }
+
+ public List<ProjectDefinition> getProjects() {
+ return collectProjects(root, new ArrayList<ProjectDefinition>());
+ }
+
+ /**
+ * Populates list of projects from hierarchy.
+ */
+ private static List<ProjectDefinition> collectProjects(ProjectDefinition def, List<ProjectDefinition> collected) {
+ collected.add(def);
+ for (ProjectDefinition child : def.getSubProjects()) {
+ collectProjects(child, collected);
+ }
+ return collected;
+ }
+
+ public ProjectDefinition getRoot() {
+ return root;
+ }
+
+ public ProjectDefinition getProject(String key) {
+ for (ProjectDefinition p : getProjects()) {
+ if (key.equals(p.getKey())) {
+ return p;
+ }
+ }
+ return null;
+ }
+}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ScanTaskTest.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ImmutableProjectReactorProvider.java
index 96730773efd..6ca8bf9f992 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ScanTaskTest.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ImmutableProjectReactorProvider.java
@@ -19,16 +19,22 @@
*/
package org.sonar.batch.scan;
-import org.junit.Test;
-import org.sonar.api.CoreProperties;
+import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
-import static org.assertj.core.api.Assertions.assertThat;
+public class ImmutableProjectReactorProvider extends ProviderAdapter {
-public class ScanTaskTest {
- @Test
- public void test_definition() {
- assertThat(ScanTask.DEFINITION).isNotNull();
- assertThat(ScanTask.DEFINITION.key()).isEqualTo(CoreProperties.SCAN_TASK);
- }
+ public ImmutableProjectReactor provide(ProjectReactor reactor, ProjectBuildersExecutor projectBuildersExecutor, ProjectExclusions exclusions, ProjectReactorValidator validator) {
+
+ // 1 Apply project builders
+ projectBuildersExecutor.execute(reactor);
+
+ // 2 Apply project exclusions
+ exclusions.apply(reactor);
+ // 3 Validate final reactor
+ validator.validate(reactor);
+
+ return new ImmutableProjectReactor(reactor.getRoot());
+ }
}
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 e3e808b914d..8284eb884c2 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
@@ -29,7 +29,7 @@ import org.sonar.api.checks.NoSonarFilter;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.api.resources.Project;
import org.sonar.api.scan.filesystem.FileExclusions;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.ExtensionInstaller;
@@ -40,7 +40,6 @@ import org.sonar.batch.deprecated.ResourceFilters;
import org.sonar.batch.deprecated.components.DefaultProjectClasspath;
import org.sonar.batch.deprecated.components.DefaultTimeMachine;
import org.sonar.batch.deprecated.perspectives.BatchPerspectives;
-import org.sonar.batch.events.EventBus;
import org.sonar.batch.index.DefaultIndex;
import org.sonar.batch.issue.IssuableFactory;
import org.sonar.batch.issue.IssueFilters;
@@ -55,7 +54,6 @@ import org.sonar.batch.phases.DecoratorsExecutor;
import org.sonar.batch.phases.InitializersExecutor;
import org.sonar.batch.phases.PersistersExecutor;
import org.sonar.batch.phases.PhaseExecutor;
-import org.sonar.batch.phases.PhasesTimeProfiler;
import org.sonar.batch.phases.PostJobsExecutor;
import org.sonar.batch.phases.ProjectInitializer;
import org.sonar.batch.phases.SensorsExecutor;
@@ -107,7 +105,7 @@ public class ModuleScanContainer extends ComponentContainer {
}
private void addCoreComponents() {
- ProjectDefinition moduleDefinition = getComponentByType(ProjectTree.class).getProjectDefinition(module);
+ ProjectDefinition moduleDefinition = getComponentByType(DefaultProjectTree.class).getProjectDefinition(module);
add(
moduleDefinition,
module,
@@ -121,8 +119,6 @@ public class ModuleScanContainer extends ComponentContainer {
Periods.class,
PhaseExecutor.class,
RuleFinderCompatibility.class,
- EventBus.class,
- PhasesTimeProfiler.class,
PostJobsExecutor.class,
DecoratorsExecutor.class,
SensorsExecutor.class,
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/MutableProjectReactorProvider.java b/sonar-batch/src/main/java/org/sonar/batch/scan/MutableProjectReactorProvider.java
new file mode 100644
index 00000000000..412da07aef6
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/MutableProjectReactorProvider.java
@@ -0,0 +1,56 @@
+/*
+ * 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;
+
+import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.batch.bootstrap.ProjectBootstrapper;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.utils.SonarException;
+import org.sonar.batch.bootstrap.AnalysisProperties;
+
+import javax.annotation.Nullable;
+
+public class MutableProjectReactorProvider extends ProviderAdapter {
+
+ private final ProjectBootstrapper projectBootstrapper;
+ private ProjectReactor reactor = null;
+
+ public MutableProjectReactorProvider(@Nullable ProjectBootstrapper projectBootstrapper) {
+ this.projectBootstrapper = projectBootstrapper;
+ }
+
+ public ProjectReactor provide(ProjectReactorBuilder builder, AnalysisProperties settings) {
+ if (reactor == null) {
+ // Look for a deprecated custom ProjectBootstrapper for old versions of SQ Runner
+ if (projectBootstrapper == null
+ // Starting from Maven plugin 2.3 then only DefaultProjectBootstrapper should be used.
+ || "true".equals(settings.property("sonar.mojoUseRunner"))) {
+ // Use default SonarRunner project bootstrapper
+ reactor = builder.execute();
+ } else {
+ reactor = projectBootstrapper.bootstrap();
+ }
+ if (reactor == null) {
+ throw new SonarException(projectBootstrapper + " has returned null as ProjectReactor");
+ }
+ }
+ return reactor;
+ }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectBuildersExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectBuildersExecutor.java
new file mode 100644
index 00000000000..ac15206c6f3
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectBuildersExecutor.java
@@ -0,0 +1,56 @@
+/*
+ * 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;
+
+import org.sonar.api.batch.bootstrap.ProjectBuilder;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext;
+import org.sonar.batch.events.BatchStepEvent;
+import org.sonar.batch.events.EventBus;
+
+import javax.annotation.Nullable;
+
+public class ProjectBuildersExecutor {
+
+ private final ProjectBuilder[] projectBuilders;
+ private final EventBus eventBus;
+
+ public ProjectBuildersExecutor(EventBus eventBus, @Nullable ProjectBuilder... projectBuilders) {
+ this.eventBus = eventBus;
+ this.projectBuilders = projectBuilders;
+ }
+
+ public ProjectBuildersExecutor(EventBus eventBus) {
+ this(eventBus, new ProjectBuilder[0]);
+ }
+
+ public void execute(ProjectReactor reactor) {
+ if (projectBuilders.length > 0) {
+ String stepName = "Execute project builders";
+ eventBus.fireEvent(new BatchStepEvent(stepName, true));
+ ProjectBuilderContext context = new ProjectBuilderContext(reactor);
+
+ for (ProjectBuilder projectBuilder : projectBuilders) {
+ projectBuilder.build(context);
+ }
+ eventBus.fireEvent(new BatchStepEvent(stepName, false));
+ }
+ }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java
index c1333e0ad47..f428779d0fe 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java
@@ -24,38 +24,26 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.bootstrap.ProjectBuilder;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.config.Settings;
-import org.sonar.api.task.TaskComponent;
-
-import javax.annotation.Nullable;
/**
* Exclude the sub-projects as defined by the properties sonar.skippedModules and sonar.includedModules
*
* @since 2.12
*/
-public class ProjectExclusions implements TaskComponent {
+public class ProjectExclusions {
private static final Logger LOG = LoggerFactory.getLogger(ProjectExclusions.class);
private Settings settings;
- private ProjectReactor reactor;
- public ProjectExclusions(Settings settings, ProjectReactor reactor,
- // exclusions are applied when the project is completely defined by extensions
- @Nullable ProjectBuilder[] projectBuilders) {
+ public ProjectExclusions(Settings settings) {
this.settings = settings;
- this.reactor = reactor;
- }
-
- public ProjectExclusions(Settings settings, ProjectReactor reactor) {
- this(settings, reactor, new ProjectBuilder[0]);
}
- public void apply() {
+ public void apply(ProjectReactor reactor) {
if (!reactor.getProjects().isEmpty() && StringUtils.isNotBlank(reactor.getProjects().get(0).getKey())) {
LOG.info("Apply project exclusions");
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectLock.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectLock.java
index 35fe0952eee..bdd70c14d60 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectLock.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectLock.java
@@ -26,7 +26,7 @@ import org.sonar.api.i18n.I18n;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.Semaphores;
import org.sonar.api.utils.SonarException;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import java.util.Locale;
@@ -36,11 +36,11 @@ public class ProjectLock {
private static final Logger LOG = LoggerFactory.getLogger(ProjectLock.class);
private final Semaphores semaphores;
- private final ProjectTree projectTree;
+ private final DefaultProjectTree projectTree;
private final DefaultAnalysisMode analysisMode;
private final I18n i18n;
- public ProjectLock(Semaphores semaphores, ProjectTree projectTree, DefaultAnalysisMode analysisMode, I18n i18n) {
+ public ProjectLock(Semaphores semaphores, DefaultProjectTree projectTree, DefaultAnalysisMode analysisMode, I18n i18n) {
this.semaphores = semaphores;
this.projectTree = projectTree;
this.analysisMode = analysisMode;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java
index e3ef6349a51..3c63472ede6 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java
@@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.batch.bootstrap.TaskProperties;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.batch.util.BatchUtils;
import javax.annotation.CheckForNull;
@@ -104,10 +104,10 @@ public class ProjectReactorBuilder {
private static final List<String> NON_HERITED_PROPERTIES_FOR_CHILD = Lists.newArrayList(PROPERTY_PROJECT_BASEDIR, CoreProperties.WORKING_DIRECTORY, PROPERTY_MODULES,
CoreProperties.PROJECT_DESCRIPTION_PROPERTY);
- private TaskProperties taskProps;
+ private AnalysisProperties taskProps;
private File rootProjectWorkDir;
- public ProjectReactorBuilder(TaskProperties props) {
+ public ProjectReactorBuilder(AnalysisProperties props) {
this.taskProps = props;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java
deleted file mode 100644
index 85ea965e514..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java
+++ /dev/null
@@ -1,72 +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;
-
-import org.sonar.api.batch.bootstrap.ProjectBuilder;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext;
-
-import javax.annotation.Nullable;
-
-/**
- * Barrier to control the project lifecycle :
- * <p/>
- * <ul>
- * <li>initialize the project configuration by executing ProjectBuilder extensions</li>
- * <li>apply sub-project exclusions (sonar.skippedModules, ...)</li>
- * <li>---- this barrier ----</li>
- * <li>run optional dry run database</li>
- * <li>connect to dry-run or remote database</li>
- * </ul>
- */
-public class ProjectReactorReady {
-
- private final ProjectReactor reactor;
- private final ProjectBuilder[] projectBuilders;
- private final ProjectExclusions exclusions;
- private final ProjectReactorValidator validator;
-
- public ProjectReactorReady(ProjectExclusions exclusions, ProjectReactor reactor, @Nullable ProjectBuilder[] projectBuilders, ProjectReactorValidator validator) {
- this.exclusions = exclusions;
- this.reactor = reactor;
- this.projectBuilders = projectBuilders;
- this.validator = validator;
- }
-
- public ProjectReactorReady(ProjectExclusions exclusions, ProjectReactor reactor, ProjectReactorValidator validator) {
- this(exclusions, reactor, new ProjectBuilder[0], validator);
- }
-
- public void start() {
- // 1 Apply project builders
- ProjectBuilderContext context = new ProjectBuilderContext(reactor);
-
- for (ProjectBuilder projectBuilder : projectBuilders) {
- projectBuilder.build(context);
- }
-
- // 2 Apply project exclusions
- exclusions.apply();
-
- // 3 Validate final reactor
- validator.validate(reactor);
-
- }
-}
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 4105dab49c1..6406f75ab2c 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
@@ -23,26 +23,28 @@ import com.google.common.annotations.VisibleForTesting;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.bootstrap.ProjectBootstrapper;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.config.Settings;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.api.resources.Languages;
import org.sonar.api.resources.Project;
+import org.sonar.api.resources.ResourceTypes;
import org.sonar.api.scan.filesystem.PathResolver;
-import org.sonar.api.utils.SonarException;
import org.sonar.batch.DefaultFileLinesContextFactory;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.ProjectConfigurator;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.ExtensionInstaller;
import org.sonar.batch.bootstrap.ExtensionMatcher;
import org.sonar.batch.bootstrap.ExtensionUtils;
import org.sonar.batch.bootstrap.MetricProvider;
+import org.sonar.batch.bootstrapper.EnvironmentInformation;
import org.sonar.batch.components.PastMeasuresLoader;
import org.sonar.batch.debt.DebtModelProvider;
import org.sonar.batch.deprecated.components.DefaultResourceCreationLock;
import org.sonar.batch.deprecated.components.PeriodsDefinition;
import org.sonar.batch.duplication.DuplicationCache;
+import org.sonar.batch.events.EventBus;
import org.sonar.batch.index.Caches;
import org.sonar.batch.index.DefaultIndex;
import org.sonar.batch.index.DependencyPersister;
@@ -56,6 +58,7 @@ import org.sonar.batch.issue.tracking.LocalIssueTracking;
import org.sonar.batch.issue.tracking.ServerIssueRepository;
import org.sonar.batch.mediumtest.ScanTaskObservers;
import org.sonar.batch.phases.GraphPersister;
+import org.sonar.batch.phases.PhasesTimeProfiler;
import org.sonar.batch.profiling.PhasesSumUpTimeProfiler;
import org.sonar.batch.qualitygate.QualityGateProvider;
import org.sonar.batch.report.ComponentsPublisher;
@@ -80,6 +83,8 @@ import org.sonar.core.component.ScanGraph;
import org.sonar.core.issue.IssueUpdater;
import org.sonar.core.issue.workflow.FunctionExecutor;
import org.sonar.core.issue.workflow.IssueWorkflow;
+import org.sonar.core.permission.PermissionFacade;
+import org.sonar.core.resource.DefaultResourcePermissions;
import org.sonar.core.technicaldebt.DefaultTechnicalDebtModel;
import org.sonar.core.test.TestPlanBuilder;
import org.sonar.core.test.TestPlanPerspectiveLoader;
@@ -89,16 +94,22 @@ import org.sonar.core.user.DefaultUserFinder;
public class ProjectScanContainer extends ComponentContainer {
- private DefaultAnalysisMode analysisMode;
+ private final DefaultAnalysisMode analysisMode;
+ private final Object[] components;
+ private final AnalysisProperties props;
- public ProjectScanContainer(ComponentContainer taskContainer) {
- super(taskContainer);
- analysisMode = taskContainer.getComponentByType(DefaultAnalysisMode.class);
+ public ProjectScanContainer(ComponentContainer globalContainer, AnalysisProperties props, Object... components) {
+ super(globalContainer);
+ this.props = props;
+ this.components = components;
+ analysisMode = globalContainer.getComponentByType(DefaultAnalysisMode.class);
}
@Override
protected void doBeforeStart() {
- projectBootstrap();
+ for (Object component : components) {
+ add(component);
+ }
addBatchComponents();
if (analysisMode.isDb()) {
addDataBaseComponents();
@@ -110,31 +121,34 @@ public class ProjectScanContainer extends ComponentContainer {
}
}
- private void projectBootstrap() {
- // Views pass a custom ProjectReactor
- ProjectReactor reactor = getComponentByType(ProjectReactor.class);
- if (reactor == null) {
- // OK, not present, so look for a deprecated custom ProjectBootstrapper for old versions of SQ Runner
- ProjectBootstrapper bootstrapper = getComponentByType(ProjectBootstrapper.class);
- Settings settings = getComponentByType(Settings.class);
- if (bootstrapper == null
- // Starting from Maven plugin 2.3 then only DefaultProjectBootstrapper should be used.
- || "true".equals(settings.getString("sonar.mojoUseRunner"))) {
- // Use default SonarRunner project bootstrapper
- ProjectReactorBuilder builder = getComponentByType(ProjectReactorBuilder.class);
- reactor = builder.execute();
- } else {
- reactor = bootstrapper.bootstrap();
- }
- if (reactor == null) {
- throw new SonarException(bootstrapper + " has returned null as ProjectReactor");
- }
- add(reactor);
+ private Class<?> projectReactorBuilder() {
+ if (isRunnerVersionLessThan2Dot4()) {
+ return DeprecatedProjectReactorBuilder.class;
}
+ return ProjectReactorBuilder.class;
+ }
+
+ private boolean isRunnerVersionLessThan2Dot4() {
+ EnvironmentInformation env = this.getComponentByType(EnvironmentInformation.class);
+ // Starting from SQ Runner 2.4 the key is "SonarQubeRunner"
+ return env != null && "SonarRunner".equals(env.getKey());
}
private void addBatchComponents() {
add(
+ props,
+ projectReactorBuilder(),
+ new MutableProjectReactorProvider(getComponentByType(ProjectBootstrapper.class)),
+ new ImmutableProjectReactorProvider(),
+ ProjectBuildersExecutor.class,
+ EventBus.class,
+ PhasesTimeProfiler.class,
+ ResourceTypes.class,
+ PermissionFacade.class,
+ DefaultResourcePermissions.class,
+ DefaultProjectTree.class,
+ ProjectExclusions.class,
+ ProjectReactorValidator.class,
new ProjectRepositoriesProvider(),
DefaultResourceCreationLock.class,
CodeColorizers.class,
@@ -238,7 +252,7 @@ public class ProjectScanContainer extends ComponentContainer {
@Override
protected void doAfterStart() {
- ProjectTree tree = getComponentByType(ProjectTree.class);
+ DefaultProjectTree tree = getComponentByType(DefaultProjectTree.class);
scanRecursively(tree.getRootProject());
if (analysisMode.isMediumTest()) {
getComponentByType(ScanTaskObservers.class).notifyEndOfScanTask();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
index 07194809cc8..e125dd24d64 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
@@ -35,16 +35,16 @@ public class ProjectSettings extends Settings {
private static final Logger LOG = LoggerFactory.getLogger(ProjectSettings.class);
private final GlobalSettings globalSettings;
- private final ProjectRepositories projectReferentials;
+ private final ProjectRepositories projectRepositories;
private final DefaultAnalysisMode mode;
public ProjectSettings(ProjectReactor reactor, GlobalSettings globalSettings, PropertyDefinitions propertyDefinitions,
- ProjectRepositories projectReferentials, DefaultAnalysisMode mode) {
+ ProjectRepositories projectRepositories, DefaultAnalysisMode mode) {
super(propertyDefinitions);
this.mode = mode;
getEncryption().setPathToSecretKey(globalSettings.getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
this.globalSettings = globalSettings;
- this.projectReferentials = projectReferentials;
+ this.projectRepositories = projectRepositories;
init(reactor);
}
@@ -53,7 +53,7 @@ public class ProjectSettings extends Settings {
addProperties(globalSettings.getProperties());
- addProperties(projectReferentials.settings(reactor.getRoot().getKeyWithBranch()));
+ addProperties(projectRepositories.settings(reactor.getRoot().getKeyWithBranch()));
addProperties(reactor.getRoot().properties());
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java
deleted file mode 100644
index f6d8a8b59ac..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java
+++ /dev/null
@@ -1,56 +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;
-
-import org.sonar.api.CoreProperties;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.api.task.Task;
-import org.sonar.api.task.TaskDefinition;
-import org.sonar.batch.DefaultProjectTree;
-import org.sonar.batch.bootstrap.TaskContainer;
-
-public class ScanTask implements Task {
- public static final TaskDefinition DEFINITION = TaskDefinition.builder()
- .description("Scan project")
- .key(CoreProperties.SCAN_TASK)
- .taskClass(ScanTask.class)
- .build();
-
- private final ComponentContainer taskContainer;
-
- public ScanTask(TaskContainer taskContainer) {
- this.taskContainer = taskContainer;
- }
-
- @Override
- public void execute() {
- scan(new org.sonar.batch.scan.ProjectScanContainer(taskContainer));
- }
-
- // Add components specific to project scan (views will use different ones)
- void scan(ComponentContainer scanContainer) {
- scanContainer.add(
- DefaultProjectTree.class,
- ProjectExclusions.class,
- ProjectReactorValidator.class,
- ProjectReactorReady.class);
- scanContainer.execute();
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java
index f98704634a1..f832ad7a03f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java
@@ -29,7 +29,7 @@ import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
import org.sonar.api.rules.RulePriority;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.index.BatchResource;
import org.sonar.batch.index.ResourceCache;
import org.sonar.batch.issue.IssueCache;
@@ -45,10 +45,10 @@ public class IssuesReportBuilder {
private final IssueCache issueCache;
private final RuleFinder ruleFinder;
private final ResourceCache resourceCache;
- private final ProjectTree projectTree;
+ private final DefaultProjectTree projectTree;
private final InputPathCache inputPathCache;
- public IssuesReportBuilder(IssueCache issueCache, RuleFinder ruleFinder, ResourceCache resourceCache, ProjectTree projectTree, InputPathCache inputPathCache) {
+ public IssuesReportBuilder(IssueCache issueCache, RuleFinder ruleFinder, ResourceCache resourceCache, DefaultProjectTree projectTree, InputPathCache inputPathCache) {
this.issueCache = issueCache;
this.ruleFinder = ruleFinder;
this.resourceCache = resourceCache;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java
index 6f7e0c11e32..a96f8570550 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java
@@ -22,7 +22,15 @@ package org.sonar.batch.bootstrap;
import com.google.common.collect.Lists;
import org.junit.Test;
import org.sonar.api.BatchExtension;
-import org.sonar.api.batch.*;
+import org.sonar.api.batch.BuildBreaker;
+import org.sonar.api.batch.CheckProject;
+import org.sonar.api.batch.Decorator;
+import org.sonar.api.batch.DependedUpon;
+import org.sonar.api.batch.DependsUpon;
+import org.sonar.api.batch.Phase;
+import org.sonar.api.batch.PostJob;
+import org.sonar.api.batch.Sensor;
+import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.postjob.PostJobContext;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.api.resources.Project;
@@ -42,9 +50,9 @@ import static org.mockito.Mockito.mock;
public class BatchExtensionDictionnaryTest {
- private BatchExtensionDictionnary newSelector(BatchExtension... extensions) {
+ private BatchExtensionDictionnary newSelector(Object... extensions) {
ComponentContainer iocContainer = new ComponentContainer();
- for (BatchExtension extension : extensions) {
+ for (Object extension : extensions) {
iocContainer.addSingleton(extension);
}
return new BatchExtensionDictionnary(iocContainer, mock(DefaultSensorContext.class), mock(SensorOptimizer.class), mock(PostJobContext.class),
@@ -80,9 +88,9 @@ public class BatchExtensionDictionnaryTest {
@Test
public void shouldSearchInParentContainers() {
- BatchExtension a = new FakeSensor();
- BatchExtension b = new FakeSensor();
- BatchExtension c = new FakeSensor();
+ Sensor a = new FakeSensor();
+ Sensor b = new FakeSensor();
+ Sensor c = new FakeSensor();
ComponentContainer grandParent = new ComponentContainer();
grandParent.addSingleton(a);
@@ -95,7 +103,7 @@ public class BatchExtensionDictionnaryTest {
BatchExtensionDictionnary dictionnary = new BatchExtensionDictionnary(child, mock(DefaultSensorContext.class), mock(SensorOptimizer.class), mock(PostJobContext.class),
mock(PostJobOptimizer.class));
- assertThat(dictionnary.select(BatchExtension.class, null, true, null)).containsOnly(a, b, c);
+ assertThat(dictionnary.select(Sensor.class, null, true, null)).containsOnly(a, b, c);
}
@Test
@@ -303,7 +311,7 @@ public class BatchExtensionDictionnaryTest {
};
BatchExtensionDictionnary selector = newSelector(new FakePostJob(), checker, new FakePostJob());
- List extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true, null));
+ List extensions = Lists.newArrayList(selector.select(PostJob.class, null, true, null));
assertThat(extensions).hasSize(3);
assertThat(extensions.get(2)).isEqualTo(checker);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskContainerTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskContainerTest.java
deleted file mode 100644
index 9d5ff90cb72..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskContainerTest.java
+++ /dev/null
@@ -1,61 +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.bootstrap;
-
-import com.google.common.collect.Lists;
-import org.junit.Test;
-import org.sonar.batch.bootstrapper.EnvironmentInformation;
-import org.sonar.batch.scan.DeprecatedProjectReactorBuilder;
-import org.sonar.batch.scan.ProjectReactorBuilder;
-
-import java.util.Collections;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class TaskContainerTest {
-
- @Test
- public void should_add_project_reactor_builder_by_default() {
- GlobalContainer container = GlobalContainer.create(Collections.<String, String>emptyMap(),
- Lists.newArrayList(new BootstrapProperties(Collections.<String, String>emptyMap())));
- TaskContainer taskContainer = new TaskContainer(container, Collections.<String, String>emptyMap());
- taskContainer.installCoreTasks();
-
- assertThat(taskContainer.getComponentByType(ProjectReactorBuilder.class)).isNotNull().isInstanceOf(ProjectReactorBuilder.class);
-
- container = GlobalContainer.create(Collections.<String, String>emptyMap(),
- Lists.newArrayList(new BootstrapProperties(Collections.<String, String>emptyMap()), new EnvironmentInformation("SonarQubeRunner", "2.4")));
- taskContainer = new TaskContainer(container, Collections.<String, String>emptyMap());
- taskContainer.installCoreTasks();
-
- assertThat(taskContainer.getComponentByType(ProjectReactorBuilder.class)).isNotNull().isInstanceOf(ProjectReactorBuilder.class);
- }
-
- @Test
- public void should_add_deprecated_project_reactor_builder_if_old_runner() {
- GlobalContainer container = GlobalContainer.create(Collections.<String, String>emptyMap(),
- Lists.newArrayList(new BootstrapProperties(Collections.<String, String>emptyMap()), new EnvironmentInformation("SonarRunner", "2.3")));
- TaskContainer taskContainer = new TaskContainer(container, Collections.<String, String>emptyMap());
- taskContainer.installCoreTasks();
-
- assertThat(taskContainer.getComponentByType(DeprecatedProjectReactorBuilder.class)).isNotNull().isInstanceOf(DeprecatedProjectReactorBuilder.class);
- }
-
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PeriodsDefinitionTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PeriodsDefinitionTest.java
index 7297da1d6aa..dbd7b178e88 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PeriodsDefinitionTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PeriodsDefinitionTest.java
@@ -20,19 +20,23 @@
package org.sonar.batch.deprecated.components;
-import org.sonar.batch.components.PastSnapshotFinder;
-
-import org.sonar.batch.deprecated.components.PeriodsDefinition;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatcher;
import org.sonar.api.config.Settings;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.resources.Project;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
+import org.sonar.batch.components.PastSnapshotFinder;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
public class PeriodsDefinitionTest extends AbstractDbUnitTestCase {
@@ -48,7 +52,7 @@ public class PeriodsDefinitionTest extends AbstractDbUnitTestCase {
@Test
public void should_init_past_snapshots() {
- ProjectTree projectTree = mock(ProjectTree.class);
+ DefaultProjectTree projectTree = mock(DefaultProjectTree.class);
when(projectTree.getRootProject()).thenReturn(new Project("my:project"));
new PeriodsDefinition(getSession(), projectTree, settings, pastSnapshotFinder);
@@ -62,7 +66,7 @@ public class PeriodsDefinitionTest extends AbstractDbUnitTestCase {
@Test
public void should_not_init_past_snapshots_if_first_analysis() {
- ProjectTree projectTree = mock(ProjectTree.class);
+ DefaultProjectTree projectTree = mock(DefaultProjectTree.class);
when(projectTree.getRootProject()).thenReturn(new Project("new:project"));
new PeriodsDefinition(getSession(), projectTree, settings, pastSnapshotFinder);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/tasks/ListTaskTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/tasks/ListTaskTest.java
deleted file mode 100644
index 2812b4d28cf..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/deprecated/tasks/ListTaskTest.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.batch.deprecated.tasks;
-
-import org.sonar.batch.deprecated.tasks.ListTask;
-import org.sonar.batch.deprecated.tasks.Tasks;
-
-import org.junit.Test;
-import org.sonar.api.task.Task;
-import org.sonar.api.task.TaskDefinition;
-
-import java.util.Arrays;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class ListTaskTest {
- @Test
- public void should_list_available_tasks() {
- Tasks tasks = mock(Tasks.class);
- when(tasks.definitions()).thenReturn(Arrays.asList(
- TaskDefinition.builder().key("foo").description("Foo").taskClass(FooTask.class).build(),
- TaskDefinition.builder().key("purge").description("Purge database").taskClass(FakePurgeTask.class).build()
- ));
-
- ListTask task = spy(new ListTask(tasks));
-
- task.execute();
-
- verify(task, times(1)).log("Available tasks:");
- verify(task, times(1)).log(" - foo: Foo");
- verify(task, times(1)).log(" - purge: Purge database");
- }
-
- private static class FakePurgeTask implements Task {
- public void execute() {
- }
- }
-
- private static class FooTask implements Task {
- public void execute() {
- }
- }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/tasks/TasksTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/tasks/TasksTest.java
deleted file mode 100644
index 51f6eb1c53b..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/deprecated/tasks/TasksTest.java
+++ /dev/null
@@ -1,92 +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.deprecated.tasks;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.task.Task;
-import org.sonar.api.task.TaskDefinition;
-import org.sonar.api.utils.SonarException;
-import org.sonar.batch.scan.ScanTask;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class TasksTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void should_get_definitions() {
- Tasks tasks = new Tasks(new TaskDefinition[] {ScanTask.DEFINITION, ListTask.DEFINITION});
- assertThat(tasks.definitions()).hasSize(2);
- }
-
- @Test
- public void should_get_definition_by_key() {
- Tasks tasks = new Tasks(new TaskDefinition[] {ScanTask.DEFINITION, ListTask.DEFINITION});
- tasks.start();
- assertThat(tasks.definition(ListTask.DEFINITION.key())).isEqualTo(ListTask.DEFINITION);
- }
-
- @Test
- public void should_return_null_if_task_not_found() {
- Tasks tasks = new Tasks(new TaskDefinition[] {ScanTask.DEFINITION, ListTask.DEFINITION});
-
- assertThat(tasks.definition("not-exists")).isNull();
- }
-
- @Test
- public void should_fail_on_duplicated_keys() {
- thrown.expect(SonarException.class);
- thrown.expectMessage("Task 'foo' is declared twice");
-
- new Tasks(new TaskDefinition[] {
- TaskDefinition.builder().key("foo").taskClass(FakeTask1.class).description("foo1").build(),
- TaskDefinition.builder().key("foo").taskClass(FakeTask2.class).description("foo2").build()
- });
- }
-
- @Test
- public void should_fail_on_duplicated_class() {
- Tasks tasks = new Tasks(new TaskDefinition[] {
- TaskDefinition.builder().key("foo1").taskClass(FakeTask1.class).description("foo1").build(),
- TaskDefinition.builder().key("foo2").taskClass(FakeTask1.class).description("foo1").build()
- });
-
- thrown.expect(SonarException.class);
- thrown.expectMessage("Task 'org.sonar.batch.deprecated.tasks.TasksTest$FakeTask1' is defined twice: first by 'foo1' and then by 'foo2'");
-
- tasks.start();
- }
-
- private static class FakeTask1 implements Task {
- public void execute() {
- }
- }
-
- private static class FakeTask2 implements Task {
- public void execute() {
- }
-
- }
-
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
index 908a8194c93..6511d57c732 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
@@ -29,10 +29,16 @@ import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilters;
import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.resources.*;
+import org.sonar.api.resources.Directory;
+import org.sonar.api.resources.File;
+import org.sonar.api.resources.Java;
+import org.sonar.api.resources.Library;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.issue.ModuleIssues;
import org.sonar.batch.scan.measure.MeasureCache;
@@ -63,7 +69,7 @@ public class DefaultIndexTest {
when(metricFinder.findByKey("ncloc")).thenReturn(CoreMetrics.NCLOC);
ruleFinder = mock(RuleFinder.class);
- ProjectTree projectTree = mock(ProjectTree.class);
+ DefaultProjectTree projectTree = mock(DefaultProjectTree.class);
ResourceCache resourceCache = new ResourceCache();
index = new DefaultIndex(resourceCache, null, projectTree, metricFinder,
mock(ResourceKeyMigration.class),
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
index 0d9be3369a4..e8e025b5297 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
@@ -30,9 +30,13 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.measure.MetricFinder;
import org.sonar.api.config.Settings;
import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.*;
+import org.sonar.api.resources.Directory;
+import org.sonar.api.resources.File;
+import org.sonar.api.resources.Library;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Resource;
import org.sonar.api.security.ResourcePermissions;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.component.ScanGraph;
@@ -66,7 +70,7 @@ public class ResourcePersisterTest extends AbstractDbUnitTestCase {
private ResourcePersister persister;
- private ProjectTree projectTree;
+ private DefaultProjectTree projectTree;
private ResourcePermissions permissions;
@@ -102,7 +106,7 @@ public class ResourcePersisterTest extends AbstractDbUnitTestCase {
moduleB1.setParent(moduleB);
moduleB1.setPath("/moduleB1");
- projectTree = mock(ProjectTree.class);
+ projectTree = mock(DefaultProjectTree.class);
permissions = mock(ResourcePermissions.class);
persister = new ResourcePersister(projectTree, getSession(), permissions, resourceCache, mock(ScanGraph.class));
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/IssuableFactoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/IssuableFactoryTest.java
index 9cac3995a5c..ac390520311 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/IssuableFactoryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/IssuableFactoryTest.java
@@ -25,7 +25,7 @@ import org.sonar.api.component.Component;
import org.sonar.api.issue.Issuable;
import org.sonar.api.resources.File;
import org.sonar.api.resources.Project;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.core.component.ResourceComponent;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,7 +35,7 @@ public class IssuableFactoryTest {
ModuleIssues moduleIssues = mock(ModuleIssues.class);
IssueCache cache = mock(IssueCache.class, Mockito.RETURNS_MOCKS);
- ProjectTree projectTree = mock(ProjectTree.class);
+ DefaultProjectTree projectTree = mock(DefaultProjectTree.class);
@Test
public void file_should_be_issuable() {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java
index f20786a4679..383a93af12e 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java
@@ -261,4 +261,15 @@ public class FileSystemMediumTest {
assertThat(result.inputFile("src/sample.other").language()).isNull();
}
+ @Test
+ public void scanMultiModuleProject() throws IOException {
+ File projectDir = new File("src/test/resources/mediumtest/xoo/multi-modules-sample");
+ TaskResult result = tester
+ .newScanTask(new File(projectDir, "sonar-project.properties"))
+ .start();
+
+ assertThat(result.inputFiles()).hasSize(4);
+ assertThat(result.inputDirs()).hasSize(4);
+ }
+
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java
index a21220d0575..0db9253b479 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java
@@ -26,7 +26,7 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.ServerClient;
-import org.sonar.batch.bootstrap.TaskProperties;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.batch.rule.ModuleQProfiles;
import static org.mockito.Matchers.anyString;
@@ -41,7 +41,7 @@ public class DefaultProjectRepositoriesLoaderTest {
private ServerClient serverClient;
private DefaultAnalysisMode analysisMode;
private ProjectReactor reactor;
- private TaskProperties taskProperties;
+ private AnalysisProperties taskProperties;
@Before
public void prepare() {
@@ -50,7 +50,7 @@ public class DefaultProjectRepositoriesLoaderTest {
loader = new DefaultProjectRepositoriesLoader(serverClient, analysisMode);
loader = spy(loader);
when(serverClient.request(anyString())).thenReturn("{}");
- taskProperties = new TaskProperties(Maps.<String, String>newHashMap(), "");
+ taskProperties = new AnalysisProperties(Maps.<String, String>newHashMap(), "");
}
@Test
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java
index bda4e1613bc..2ac5ac8bd3d 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.batch.bootstrap.TaskProperties;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.test.TestUtils;
import java.io.File;
@@ -182,7 +182,7 @@ public class DeprecatedProjectReactorBuilderTest {
props.put(name, runnerProps.getProperty(name));
}
props.put("sonar.projectBaseDir", TestUtils.getResource(this.getClass(), projectFolder).getAbsolutePath());
- TaskProperties taskProps = new TaskProperties(props, null);
+ AnalysisProperties taskProps = new AnalysisProperties(props, null);
ProjectReactor projectReactor = new DeprecatedProjectReactorBuilder(taskProps).execute();
return projectReactor.getRoot();
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java
index 703201bf1af..d55e18a6a0f 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java
@@ -44,8 +44,8 @@ public class ProjectExclusionsTest {
ProjectReactor reactor = newReactor("root", "sub1", "sub2");
- ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
- exclusions.apply();
+ ProjectExclusions exclusions = new ProjectExclusions(settings);
+ exclusions.apply(reactor);
assertThat(reactor.getProject("root")).isNotNull();
assertThat(reactor.getProject("sub1")).isNull();
@@ -56,8 +56,8 @@ public class ProjectExclusionsTest {
public void testNoSkippedModules() {
Settings settings = new Settings();
ProjectReactor reactor = newReactor("root", "sub1", "sub2");
- ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
- exclusions.apply();
+ ProjectExclusions exclusions = new ProjectExclusions(settings);
+ exclusions.apply(reactor);
assertThat(reactor.getProject("root")).isNotNull();
assertThat(reactor.getProject("sub1")).isNotNull();
@@ -69,8 +69,8 @@ public class ProjectExclusionsTest {
Settings settings = new Settings();
settings.setProperty("sonar.includedModules", "sub1");
ProjectReactor reactor = newReactor("root", "sub1", "sub2");
- ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
- exclusions.apply();
+ ProjectExclusions exclusions = new ProjectExclusions(settings);
+ exclusions.apply(reactor);
assertThat(reactor.getProject("root")).isNotNull();
assertThat(reactor.getProject("sub1")).isNotNull();
@@ -87,8 +87,8 @@ public class ProjectExclusionsTest {
settings.setProperty("sonar.skippedModules", "sub1");
ProjectReactor reactor = new ProjectReactor(root);
- ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
- exclusions.apply();
+ ProjectExclusions exclusions = new ProjectExclusions(settings);
+ exclusions.apply(reactor);
assertThat(reactor.getProject("root")).isNotNull();
assertThat(reactor.getProject("sub1")).isNull();
@@ -101,8 +101,8 @@ public class ProjectExclusionsTest {
settings.setProperty("sonar.skippedModules", "sub1,root");
ProjectReactor reactor = newReactor("root", "sub1", "sub2");
- ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
- exclusions.apply();
+ ProjectExclusions exclusions = new ProjectExclusions(settings);
+ exclusions.apply(reactor);
}
@Test
@@ -112,8 +112,8 @@ public class ProjectExclusionsTest {
Settings settings = new Settings();
settings.setProperty("sonar.skippedModules", "struts-taglib");
- ProjectExclusions exclusions = new ProjectExclusions(settings, reactor, null);
- exclusions.apply();
+ ProjectExclusions exclusions = new ProjectExclusions(settings);
+ exclusions.apply(reactor);
assertThat(reactor.getProject("org.apache.struts:struts")).isNotNull();
assertThat(reactor.getProject("org.apache.struts:struts-core")).isNotNull();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectLockTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectLockTest.java
index 6cc0ef740da..6df0b99025c 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectLockTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectLockTest.java
@@ -25,20 +25,26 @@ import org.sonar.api.i18n.I18n;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.Semaphores;
import org.sonar.api.utils.SonarException;
-import org.sonar.batch.ProjectTree;
+import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
public class ProjectLockTest {
ProjectLock projectLock;
Semaphores semaphores = mock(Semaphores.class);
- ProjectTree projectTree = mock(ProjectTree.class);
+ DefaultProjectTree projectTree = mock(DefaultProjectTree.class);
I18n i18n = mock(I18n.class);
Project project;
private DefaultAnalysisMode mode;
@@ -65,7 +71,7 @@ public class ProjectLockTest {
public void shouldNotAcquireSemaphoreIfTheProjectIsAlreadyBeenAnalysing() {
when(semaphores.acquire(anyString(), anyInt(), anyInt())).thenReturn(new Semaphores.Semaphore().setLocked(false).setDurationSinceLocked(1234L));
try {
- projectLock.start();
+ projectLock.start();
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(SonarException.class);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java
index 617149c60ec..8849aadf68a 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.batch.bootstrap.TaskProperties;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.test.TestUtils;
import java.io.File;
@@ -331,7 +331,7 @@ public class ProjectReactorBuilderTest {
public void shouldRemoveModulePropertiesFromTaskProperties() {
Map<String, String> props = loadProps("big-multi-module-definitions-all-in-root");
- TaskProperties taskProperties = new TaskProperties(props, null);
+ AnalysisProperties taskProperties = new AnalysisProperties(props, null);
assertThat(taskProperties.property("module1.module11.property")).isEqualTo("My module11 property");
new ProjectReactorBuilder(taskProperties).execute();
@@ -433,7 +433,7 @@ public class ProjectReactorBuilderTest {
@Test
public void shouldInitRootWorkDir() {
- ProjectReactorBuilder builder = new ProjectReactorBuilder(new TaskProperties(Maps.<String, String>newHashMap(), null));
+ ProjectReactorBuilder builder = new ProjectReactorBuilder(new AnalysisProperties(Maps.<String, String>newHashMap(), null));
File baseDir = new File("target/tmp/baseDir");
File workDir = builder.initRootProjectWorkDir(baseDir, Maps.<String, String>newHashMap());
@@ -445,7 +445,7 @@ public class ProjectReactorBuilderTest {
public void shouldInitWorkDirWithCustomRelativeFolder() {
Map<String, String> props = Maps.<String, String>newHashMap();
props.put("sonar.working.directory", ".foo");
- ProjectReactorBuilder builder = new ProjectReactorBuilder(new TaskProperties(props, null));
+ ProjectReactorBuilder builder = new ProjectReactorBuilder(new AnalysisProperties(props, null));
File baseDir = new File("target/tmp/baseDir");
File workDir = builder.initRootProjectWorkDir(baseDir, props);
@@ -457,7 +457,7 @@ public class ProjectReactorBuilderTest {
public void shouldInitRootWorkDirWithCustomAbsoluteFolder() {
Map<String, String> props = Maps.<String, String>newHashMap();
props.put("sonar.working.directory", new File("src").getAbsolutePath());
- ProjectReactorBuilder builder = new ProjectReactorBuilder(new TaskProperties(props, null));
+ ProjectReactorBuilder builder = new ProjectReactorBuilder(new AnalysisProperties(props, null));
File baseDir = new File("target/tmp/baseDir");
File workDir = builder.initRootProjectWorkDir(baseDir, props);
@@ -516,7 +516,7 @@ public class ProjectReactorBuilderTest {
private ProjectDefinition loadProjectDefinition(String projectFolder) {
Map<String, String> props = loadProps(projectFolder);
- TaskProperties bootstrapProps = new TaskProperties(props, null);
+ AnalysisProperties bootstrapProps = new AnalysisProperties(props, null);
ProjectReactor projectReactor = new ProjectReactorBuilder(bootstrapProps).execute();
return projectReactor.getRoot();
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorReadyTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorReadyTest.java
deleted file mode 100644
index 63f2377e67e..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorReadyTest.java
+++ /dev/null
@@ -1,42 +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;
-
-import org.junit.Test;
-import org.sonar.api.batch.bootstrap.ProjectBuilder;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-
-import static org.mockito.Mockito.mock;
-
-public class ProjectReactorReadyTest {
- @Test
- public void should_do_nothing() {
- // it's only a barrier
- ProjectReactorReady barrier = new ProjectReactorReady(mock(ProjectExclusions.class), mock(ProjectReactor.class),
- new ProjectBuilder[] {mock(ProjectBuilder.class)}, mock(ProjectReactorValidator.class));
- barrier.start();
- }
-
- @Test
- public void project_builders_should_be_optional() {
- ProjectReactorReady barrier = new ProjectReactorReady(mock(ProjectExclusions.class), mock(ProjectReactor.class), mock(ProjectReactorValidator.class));
- barrier.start();
- }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
index 7037ec35550..7c9358509c3 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
@@ -19,85 +19,16 @@
*/
package org.sonar.batch.scan;
-import org.junit.Before;
import org.junit.Test;
import org.sonar.api.BatchExtension;
-import org.sonar.api.CoreProperties;
import org.sonar.api.ServerExtension;
import org.sonar.api.batch.InstantiationStrategy;
-import org.sonar.api.batch.bootstrap.ProjectBootstrapper;
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
-import org.sonar.core.platform.ComponentContainer;
import org.sonar.api.task.TaskExtension;
-import org.sonar.api.utils.System2;
-import org.sonar.api.utils.TempFolder;
-import org.sonar.batch.bootstrap.BootstrapProperties;
-import org.sonar.batch.bootstrap.DefaultAnalysisMode;
-import org.sonar.batch.bootstrap.ExtensionInstaller;
-import org.sonar.batch.bootstrap.GlobalSettings;
-import org.sonar.batch.bootstrap.TaskProperties;
-import org.sonar.batch.profiling.PhasesSumUpTimeProfiler;
-import org.sonar.batch.protocol.input.GlobalRepositories;
-import org.sonar.batch.protocol.input.ProjectRepositories;
-import org.sonar.batch.repository.ProjectRepositoriesLoader;
-
-import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
public class ProjectScanContainerTest {
- private ProjectBootstrapper projectBootstrapper;
- private ProjectScanContainer container;
- private Settings settings;
- private ComponentContainer parentContainer;
- private BootstrapProperties bootstrapProperties;
-
- @Before
- public void prepare() {
- projectBootstrapper = mock(ProjectBootstrapper.class);
- bootstrapProperties = new BootstrapProperties(Collections.<String, String>emptyMap());
- DefaultAnalysisMode analysisMode = new DefaultAnalysisMode(Collections.<String, String>emptyMap());
- when(projectBootstrapper.bootstrap()).thenReturn(new ProjectReactor(ProjectDefinition.create()));
- parentContainer = new ComponentContainer();
- parentContainer.add(System2.INSTANCE);
- parentContainer.add(bootstrapProperties);
- parentContainer.add(analysisMode);
- GlobalRepositories globalRef = new GlobalRepositories();
- settings = new GlobalSettings(bootstrapProperties, new PropertyDefinitions(), globalRef, analysisMode);
- parentContainer.add(settings);
- ProjectRepositoriesLoader projectReferentialsLoader = new ProjectRepositoriesLoader() {
- @Override
- public ProjectRepositories load(ProjectReactor reactor, TaskProperties taskProperties) {
- return new ProjectRepositories();
- }
- };
- parentContainer.add(projectReferentialsLoader);
- parentContainer.add(mock(TaskProperties.class));
- container = new ProjectScanContainer(parentContainer);
- }
-
- @Test
- public void should_activate_profiling() {
- container.add(mock(ExtensionInstaller.class), projectBootstrapper, mock(TempFolder.class));
- container.doBeforeStart();
-
- assertThat(container.getComponentsByType(PhasesSumUpTimeProfiler.class)).hasSize(0);
-
- settings.setProperty(CoreProperties.PROFILING_LOG_PROPERTY, "true");
-
- container = new ProjectScanContainer(parentContainer);
- container.add(mock(ExtensionInstaller.class), projectBootstrapper, mock(TempFolder.class));
- container.doBeforeStart();
-
- assertThat(container.getComponentsByType(PhasesSumUpTimeProfiler.class)).hasSize(1);
- }
-
@Test
public void should_add_only_batch_extensions() {
ProjectScanContainer.BatchExtensionFilter filter = new ProjectScanContainer.BatchExtensionFilter();
diff --git a/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a1/.sonar/sonar-report.json b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a1/.sonar/sonar-report.json
new file mode 100644
index 00000000000..581142ee53c
--- /dev/null
+++ b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a1/.sonar/sonar-report.json
@@ -0,0 +1 @@
+{"version":"5.1-SNAPSHOT","issues":[{"key":"0ae8428f-42a6-4b44-befc-512f1846fdad","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":1,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"215429f4-fa2e-4611-a75b-abb4330ea36b","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":4,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"2b5d88b5-acc5-4761-bf47-3d6d46435c59","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":10,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"50fb32b3-61af-4efa-b234-5a5b048d72a1","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":16,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"52911422-9c22-4a40-982f-c7fa779e3b2c","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":2,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"5b0da657-2183-42ae-b0f9-595a0f59de17","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":15,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"70bac047-8559-4c72-bc2d-7584df7e4a0b","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":12,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"8843a921-b9bd-4837-ae0b-423d01b2476d","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":14,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"b227df4a-78e1-4624-9f48-589000d26fe9","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":8,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"b6f8a23f-de5a-4ec2-a549-ace73f0e0667","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":9,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"c7aef709-5210-4ff2-a237-be915ad611bb","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":13,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"c86663e2-6b98-4e9f-80c3-3cdea013f816","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":11,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"cddb488f-37ba-42a6-9f2a-09090c2f1c8e","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":3,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"e1d513d2-b165-41a5-9874-b0dc01fef619","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":6,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"e49d6d6e-3e2d-425b-b531-fe761757b773","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":5,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"},{"key":"f2ba9cdb-7efe-413f-981c-e6421861db46","component":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","line":7,"message":"This issue is generated on each line","severity":"MAJOR","rule":"xoo:OneIssuePerLine","status":"OPEN","isNew":false,"creationDate":"2013-05-01T00:00:00+0200"}],"components":[{"key":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1"},{"key":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","path":"src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo","moduleKey":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1","status":"SAME"},{"key":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1","path":"src/main/xoo/com/sonar/it/samples/modules/a1","moduleKey":"com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1"}],"rules":[{"key":"xoo:OneIssuePerLine","rule":"OneIssuePerLine","repository":"xoo","name":"One Issue Per Line"}],"users":[]} \ No newline at end of file
diff --git a/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo
new file mode 100644
index 00000000000..74d29a4fa08
--- /dev/null
+++ b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo
@@ -0,0 +1,16 @@
+package com.sonar.it.samples.modules.a1;
+
+public class HelloA1 {
+ private int i;
+ private HelloA1() {
+
+ }
+
+ public void hello() {
+ System.out.println("hello" + " xoo");
+ }
+
+ protected String getHello() {
+ return "hello";
+ }
+} \ No newline at end of file
diff --git a/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo
new file mode 100644
index 00000000000..42039538a92
--- /dev/null
+++ b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo
@@ -0,0 +1,12 @@
+package com.sonar.it.samples.modules.a2;
+
+public class HelloA2 {
+ private int i;
+ private HelloA2() {
+
+ }
+
+ public void hello() {
+ System.out.println("hello" + " xoo");
+ }
+} \ No newline at end of file
diff --git a/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo
new file mode 100644
index 00000000000..b83c3af128c
--- /dev/null
+++ b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo
@@ -0,0 +1,12 @@
+package com.sonar.it.samples.modules.b1;
+
+public class HelloB1 {
+ private int i;
+ private HelloB1() {
+
+ }
+
+ public void hello() {
+ System.out.println("hello" + " world");
+ }
+} \ No newline at end of file
diff --git a/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo
new file mode 100644
index 00000000000..20b8bb3876a
--- /dev/null
+++ b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo
@@ -0,0 +1,12 @@
+package com.sonar.it.samples.modules.b2;
+
+public class HelloB2 {
+ private int i;
+ private HelloB2() {
+
+ }
+
+ public void hello() {
+ System.out.println("hello" + " world");
+ }
+} \ No newline at end of file
diff --git a/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties
new file mode 100644
index 00000000000..b07be6f3e6f
--- /dev/null
+++ b/sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties
@@ -0,0 +1,31 @@
+# Root project information
+sonar.projectKey=com.sonarsource.it.samples:multi-modules-sample
+sonar.projectName=Sonar :: Integration Tests :: Multi-modules Sample
+sonar.projectVersion=1.0-SNAPSHOT
+
+sonar.language=xoo
+
+# Some properties that will be inherited by the modules
+sonar.sources=src/main/xoo
+
+# List of the module identifiers
+sonar.modules=module_a,module_b
+
+module_a.sonar.projectKey=module_a
+module_a.sonar.projectName=Module A
+
+module_a.sonar.modules=module_a1,module_a2
+
+module_a.module_a1.sonar.projectName=Sub-module A1
+
+module_a.module_a2.sonar.projectName=Sub-module A2
+
+
+module_b.sonar.projectKey=module_b
+module_b.sonar.projectName=Module B
+
+module_b.sonar.modules=module_b1,module_b2
+
+module_b.module_b1.sonar.projectName=Sub-module B1
+
+module_b.module_b2.sonar.projectName=Sub-module B2
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
index 9d59b3ef358..4b60af8f368 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
@@ -389,12 +389,16 @@ public interface CoreProperties {
/**
* @since 3.5
+ * @deprecated since 5.2 no more task concept on batch side
*/
+ @Deprecated
String TASK = "sonar.task";
/**
* @since 3.6
+ * @deprecated since 5.2 no more task concept on batch side
*/
+ @Deprecated
String SCAN_TASK = "scan";
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectBootstrapper.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectBootstrapper.java
index fd3266f27a3..ceed23bf7d1 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectBootstrapper.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectBootstrapper.java
@@ -19,7 +19,8 @@
*/
package org.sonar.api.batch.bootstrap;
-import org.sonar.api.task.TaskExtension;
+import org.sonar.api.BatchSide;
+import org.sonar.api.ExtensionPoint;
/**
* This extension point initializes the project structure. It is extended by batch bootstrappers
@@ -35,7 +36,9 @@ import org.sonar.api.task.TaskExtension;
* @deprecated since 4.3 All bootstrappers should use SQ Runner API and provide a set of properties
*/
@Deprecated
-public interface ProjectBootstrapper extends TaskExtension {
+@BatchSide
+@ExtensionPoint
+public interface ProjectBootstrapper {
/**
* Implement this method to create project reactor
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectReactor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectReactor.java
index 2d58e233af1..d062a7efc32 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectReactor.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectReactor.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.List;
/**
+ * Mutable project definitions that can be modified by {@link ProjectBuilder} extensions.
* @since 2.9
*/
@BatchSide
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/EventHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/EventHandler.java
index 412593db9ad..df63d940336 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/EventHandler.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/EventHandler.java
@@ -21,6 +21,7 @@ package org.sonar.api.batch.events;
import org.sonar.api.BatchSide;
import org.sonar.api.ExtensionPoint;
+import org.sonar.api.batch.InstantiationStrategy;
/**
* Common interface for event handlers.
@@ -29,6 +30,7 @@ import org.sonar.api.ExtensionPoint;
* @since 2.8
*/
@BatchSide
+@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
@ExtensionPoint
public interface EventHandler {