]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6536 Drop concept of task
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 11 May 2015 10:09:44 +0000 (12:09 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Mon, 11 May 2015 15:04:46 +0000 (17:04 +0200)
59 files changed:
sonar-batch/src/main/java/org/sonar/batch/DefaultProjectTree.java
sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/bootstrap/AnalysisProperties.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskProperties.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java
sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java
sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/ListTask.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/Tasks.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/deprecated/tasks/package-info.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java
sonar-batch/src/main/java/org/sonar/batch/issue/IssuableFactory.java
sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java
sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesLoader.java
sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java
sonar-batch/src/main/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilder.java
sonar-batch/src/main/java/org/sonar/batch/scan/ImmutableProjectReactor.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/scan/ImmutableProjectReactorProvider.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
sonar-batch/src/main/java/org/sonar/batch/scan/MutableProjectReactorProvider.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectBuildersExecutor.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectLock.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorReady.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java
sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java
sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskContainerTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PeriodsDefinitionTest.java
sonar-batch/src/test/java/org/sonar/batch/deprecated/tasks/ListTaskTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/deprecated/tasks/TasksTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
sonar-batch/src/test/java/org/sonar/batch/issue/IssuableFactoryTest.java
sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java
sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/DeprecatedProjectReactorBuilderTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectExclusionsTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectLockTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorReadyTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/ScanTaskTest.java [deleted file]
sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/module_a/module_a1/.sonar/sonar-report.json [new file with mode: 0644]
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 with mode: 0644]
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 with mode: 0644]
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 with mode: 0644]
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 with mode: 0644]
sonar-batch/src/test/resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectBootstrapper.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectReactor.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/events/EventHandler.java

index 1d9aeed130f65d547cb22696f7373f3f9c4dd35f..343ecb787ed0b561f1201d482a811307f59c3613 100644 (file)
@@ -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 (file)
index eb64203..0000000
+++ /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/AnalysisProperties.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/AnalysisProperties.java
new file mode 100644 (file)
index 0000000..d8b5341
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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 javax.annotation.Nullable;
+
+import java.util.Map;
+
+/**
+ * Batch properties that are specific to an analysis (for example
+ * coming from sonar-project.properties).
+ */
+public class AnalysisProperties extends UserProperties {
+
+  public AnalysisProperties(Map<String, String> properties, @Nullable String pathToSecretKey) {
+    super(properties, pathToSecretKey);
+  }
+
+}
index c5d2a431b8b05764e22fbe45c25045c9569c5c58..2b84c018c17fc4912d3ba87e26d14e5d0b23584d 100644 (file)
@@ -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 (file)
index e372178..0000000
+++ /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/bootstrap/TaskProperties.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskProperties.java
deleted file mode 100644 (file)
index d469fcd..0000000
+++ /dev/null
@@ -1,36 +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 javax.annotation.Nullable;
-
-import java.util.Map;
-
-/**
- * Batch properties that are specific to a task (for example
- * coming from sonar-project.properties).
- */
-public class TaskProperties extends UserProperties {
-
-  public TaskProperties(Map<String, String> properties, @Nullable String pathToSecretKey) {
-    super(properties, pathToSecretKey);
-  }
-
-}
index 8bcae6dcc1f8109c59936e85506e66546dfe739b..70da9601bd1180fea72cd1d5a8a4305720ec6581 100644 (file)
@@ -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;
   }
 
index 55f9b8104347af63e2bc0f262014476d1fa86448..dd3f8ee08263abc0ef8311033107a14f8647ca2e 100644 (file)
@@ -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 (file)
index bcd02a0..0000000
+++ /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 (file)
index c97bdea..0000000
+++ /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 (file)
index f346de5..0000000
+++ /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;
index 3d8cdc1f72f4caa3187cd0b13cf212f4774c617d..14803caa3b569d9ff17bca53bcd14bd184aaea00 100644 (file)
@@ -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;
index 1520a672cc5dd10aae898e3b96da07de415d3f69..d76e69c68302e659fd289d21654d8f35cf72740b 100644 (file)
@@ -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;
index d287364b046311125ca783b6fdfe0c018e45c11f..51ec2b9fe7e56518ac0c0bc74e61021afb1340cc 100644 (file)
@@ -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;
index 09871955a382949c06d5e44b746175b4277456b0..743c1e887bce71db919b68a9175d842e23ef48ef 100644 (file)
@@ -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;
     }
 
index 772f6923466ba173093d7fd1d73e54d5d94b8fe0..71f4953769e572a30d4f6f49867b0bdb25227a66 100644 (file)
@@ -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)) {
index 5471f1e511e99a48dab1d9432b386ee17a161f60..1c445fe687048d152cc6afb8f146a30848d045e3 100644 (file)
 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);
 
 }
index 283beec595ffe8d214c7a1093c57d9c27f1b745c..6e7bbf532e509ef49ca3bde76965b9e0552f7ce3 100644 (file)
@@ -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);
index 6050f938d55c372c3eeaf00ffa9dae29e647da1b..fd9786028298f04359cdfc1df27a347f7c1be219 100644 (file)
@@ -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 (file)
index 0000000..7eccc22
--- /dev/null
@@ -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/main/java/org/sonar/batch/scan/ImmutableProjectReactorProvider.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ImmutableProjectReactorProvider.java
new file mode 100644 (file)
index 0000000..6ca8bf9
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.ProjectReactor;
+
+public class ImmutableProjectReactorProvider extends ProviderAdapter {
+
+  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());
+  }
+}
index e3e808b914dcefc11fc0378b461964a3400548e2..8284eb884c2245dc08a20334fbe958e02a3c503c 100644 (file)
@@ -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 (file)
index 0000000..412da07
--- /dev/null
@@ -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 (file)
index 0000000..ac15206
--- /dev/null
@@ -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));
+    }
+  }
+}
index c1333e0ad47ccf595164fcf608411701ddc99334..f428779d0fef818952eca9fee9a754a20e9a3146 100644 (file)
@@ -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");
 
index 35fe0952eee9f560e5de6b14c27171c031b36b00..bdd70c14d601fd0d2af1a060b65a8a144df62e94 100644 (file)
@@ -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;
index e3ef6349a51616d8b04889fbd2e8dd71107676bd..3c63472ede60c36d009f2db0319770ab2f6f38ab 100644 (file)
@@ -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 (file)
index 85ea965..0000000
+++ /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);
-
-  }
-}
index 4105dab49c1edf86b5e2f49fcbab61375d8ef75b..6406f75ab2c96073da741c8b68e248781ca21968 100644 (file)
@@ -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();
index 07194809cc84295e7b5436734186dd392ee6c879..e125dd24d6456bc1832d2d51d8521426f4bae68d 100644 (file)
@@ -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 (file)
index f6d8a8b..0000000
+++ /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();
-  }
-}
index f98704634a13eb7f1f29f4180bf8f96b958ad423..f832ad7a03f36fc2e64587696058651eb5ee3a44 100644 (file)
@@ -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;
index 6f7e0c11e3245605f2d24887b697e8ecb9127a2e..a96f8570550e14ef0f859bd773fd564d53802a36 100644 (file)
@@ -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 (file)
index 9d5ff90..0000000
+++ /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);
-  }
-
-}
index 7297da1d6aa76acd8af6fbea7916a2cd4eac03f6..dbd7b178e88df93c3831930a55ec1dc0504921e3 100644 (file)
 
 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 (file)
index 2812b4d..0000000
+++ /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 (file)
index 51f6eb1..0000000
+++ /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() {
-    }
-
-  }
-
-}
index 908a8194c93a0fdf6821ef7ad9a9640794615a4d..6511d57c732c82f7a2abe941da2a112dc43c0627 100644 (file)
@@ -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),
index 0d9be3369a4ab4f475a1e9ba5f389f875529f418..e8e025b529746218145f2948947e10cd11eae7b5 100644 (file)
@@ -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));
   }
index 9cac3995a5c0d279ae06d8b82ebff39c09b8a30e..ac390520311ed4e7ae5661bc7ded67baec1c691d 100644 (file)
@@ -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() {
index f20786a467905e4ddedd6dadc0c5fccd4c410eaf..383a93af12eb9a10e34293e404213bd93cd0346f 100644 (file)
@@ -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);
+  }
+
 }
index a21220d057525998955bf2140aa4fd230b366ab6..0db9253b47919c0e914cbce52110410e30be9a9e 100644 (file)
@@ -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
index bda4e1613bc68f089a93040c307d3f93b8e54e35..2ac5ac8bd3db089ff6d3242611f8272a4b711c1e 100644 (file)
@@ -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();
   }
index 703201bf1af465a636c4c0685ae3fcbb60c987fd..d55e18a6a0f5cb7299bc30161c2ceec9ed9fb32d 100644 (file)
@@ -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();
index 6cc0ef740dab31a0e6c39b5e7dc727e4da5a497d..6df0b99025cfb832a005f5350278ca27d76b7cad 100644 (file)
@@ -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);
index 617149c60ecb4458dc19a67482b743e8a9f6034b..8849aadf68a905d76e62bdcd31a9a391e5825649 100644 (file)
@@ -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 (file)
index 63f2377..0000000
+++ /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();
-  }
-}
index 7037ec35550a8d8db97ead5a327df097ef88ef62..7c9358509c3f2c6a04c44d54a53686465229b08d 100644 (file)
  */
 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/java/org/sonar/batch/scan/ScanTaskTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ScanTaskTest.java
deleted file mode 100644 (file)
index 9673077..0000000
+++ /dev/null
@@ -1,34 +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.CoreProperties;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class ScanTaskTest {
-  @Test
-  public void test_definition() {
-    assertThat(ScanTask.DEFINITION).isNotNull();
-    assertThat(ScanTask.DEFINITION.key()).isEqualTo(CoreProperties.SCAN_TASK);
-  }
-
-}
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 (file)
index 0000000..581142e
--- /dev/null
@@ -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 (file)
index 0000000..74d29a4
--- /dev/null
@@ -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 (file)
index 0000000..4203953
--- /dev/null
@@ -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 (file)
index 0000000..b83c3af
--- /dev/null
@@ -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 (file)
index 0000000..20b8bb3
--- /dev/null
@@ -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 (file)
index 0000000..b07be6f
--- /dev/null
@@ -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
index 9d59b3ef358cf8aeadc187b3d0bebd1145f17abe..4b60af8f3681ef71385b371e0869bc6523c3201d 100644 (file)
@@ -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";
 
   /**
index fd3266f27a392a04b32d1dcfa854158dada93114..ceed23bf7d1d73e08207da5f39b48001d5f61fe8 100644 (file)
@@ -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
index 2d58e233af1f313cd7e425bd92a5f74a3da63154..d062a7efc32024acc81d9bdbb92b36e72c442918 100644 (file)
@@ -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
index 412593db9ad6e45d9c5c3ecb010b196a86370bbe..df63d940336dd4cfd3017f1e6d83932e6406bd83 100644 (file)
@@ -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 {