]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4069 Refactoring of Task extension
authorJulien HENRY <julien.henry@sonarsource.com>
Fri, 18 Jan 2013 14:40:58 +0000 (15:40 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Fri, 18 Jan 2013 14:43:09 +0000 (15:43 +0100)
* @RequiresProject is no more in API
* Simplify TaskModule

sonar-batch/src/main/java/org/sonar/batch/bootstrap/AbstractTaskModule.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectLessTaskModule.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectTaskModule.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskBootstrapModule.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskModule.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/tasks/InspectionTask.java
sonar-batch/src/main/java/org/sonar/batch/tasks/RequiresProject.java [new file with mode: 0644]
sonar-batch/src/test/java/org/sonar/batch/bootstrap/AbstractTaskModuleTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskModuleTest.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/task/RequiresProject.java [deleted file]

diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/AbstractTaskModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/AbstractTaskModule.java
deleted file mode 100644 (file)
index c433bb8..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.batch.bootstrap;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.config.EmailSettings;
-import org.sonar.api.resources.ResourceTypes;
-import org.sonar.api.task.Task;
-import org.sonar.api.task.TaskDefinition;
-import org.sonar.api.utils.SonarException;
-import org.sonar.batch.DefaultResourceCreationLock;
-import org.sonar.batch.components.PastMeasuresLoader;
-import org.sonar.batch.components.PastSnapshotFinder;
-import org.sonar.batch.components.PastSnapshotFinderByDate;
-import org.sonar.batch.components.PastSnapshotFinderByDays;
-import org.sonar.batch.components.PastSnapshotFinderByPreviousAnalysis;
-import org.sonar.batch.components.PastSnapshotFinderByPreviousVersion;
-import org.sonar.batch.components.PastSnapshotFinderByVersion;
-import org.sonar.batch.index.DefaultPersistenceManager;
-import org.sonar.batch.index.DefaultResourcePersister;
-import org.sonar.batch.index.DependencyPersister;
-import org.sonar.batch.index.EventPersister;
-import org.sonar.batch.index.LinkPersister;
-import org.sonar.batch.index.MeasurePersister;
-import org.sonar.batch.index.MemoryOptimizer;
-import org.sonar.batch.index.SourcePersister;
-import org.sonar.batch.tasks.ListTasksTask;
-import org.sonar.core.i18n.I18nManager;
-import org.sonar.core.i18n.RuleI18nManager;
-import org.sonar.core.metric.CacheMetricFinder;
-import org.sonar.core.notification.DefaultNotificationManager;
-import org.sonar.core.persistence.DaoUtils;
-import org.sonar.core.persistence.DatabaseVersion;
-import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SemaphoresImpl;
-import org.sonar.core.resource.DefaultResourcePermissions;
-import org.sonar.core.rule.CacheRuleFinder;
-import org.sonar.core.user.DefaultUserFinder;
-import org.sonar.jpa.dao.MeasuresDao;
-import org.sonar.jpa.session.DefaultDatabaseConnector;
-import org.sonar.jpa.session.JpaDatabaseSession;
-
-/**
- * Level-3 components. Task-level components that don't depends on project.
- */
-public abstract class AbstractTaskModule extends Module {
-
-  private static final Logger LOG = LoggerFactory.getLogger(AbstractTaskModule.class);
-
-  private TaskDefinition taskDefinition;
-  private boolean projectPresent;
-
-  public AbstractTaskModule(TaskDefinition task, boolean projectPresent) {
-    this.taskDefinition = task;
-    this.projectPresent = projectPresent;
-  }
-
-  @Override
-  protected void configure() {
-    logSettings();
-    registerCoreComponents();
-    registerDatabaseComponents();
-    registerTaskExtensions();
-    registerCoreTasks();
-  }
-
-  private void registerCoreComponents() {
-    container.addSingleton(EmailSettings.class);
-    container.addSingleton(I18nManager.class);
-    container.addSingleton(RuleI18nManager.class);
-    container.addSingleton(DefaultResourceCreationLock.class);
-
-    container.addSingleton(DefaultPersistenceManager.class);
-    container.addSingleton(DependencyPersister.class);
-    container.addSingleton(EventPersister.class);
-    container.addSingleton(LinkPersister.class);
-    container.addSingleton(MeasurePersister.class);
-
-    container.addSingleton(MemoryOptimizer.class);
-    container.addSingleton(DefaultResourcePermissions.class);
-    container.addSingleton(DefaultResourcePersister.class);
-    container.addSingleton(SourcePersister.class);
-    container.addSingleton(MeasuresDao.class);
-    container.addSingleton(CacheRuleFinder.class);
-    container.addSingleton(CacheMetricFinder.class);
-    container.addSingleton(PastSnapshotFinderByDate.class);
-    container.addSingleton(PastSnapshotFinderByDays.class);
-    container.addSingleton(PastSnapshotFinderByPreviousAnalysis.class);
-    container.addSingleton(PastSnapshotFinderByVersion.class);
-    container.addSingleton(PastSnapshotFinderByPreviousVersion.class);
-    container.addSingleton(PastMeasuresLoader.class);
-    container.addSingleton(PastSnapshotFinder.class);
-    container.addSingleton(DefaultNotificationManager.class);
-    container.addSingleton(DefaultUserFinder.class);
-    container.addSingleton(ResourceTypes.class);
-    container.addSingleton(SemaphoresImpl.class);
-    container.addSingleton(MetricProvider.class);
-  }
-
-  private void registerDatabaseComponents() {
-    container.addSingleton(JdbcDriverHolder.class);
-    container.addSingleton(BatchDatabase.class);
-    container.addSingleton(MyBatis.class);
-    container.addSingleton(DatabaseVersion.class);
-    container.addSingleton(DatabaseCompatibility.class);
-    for (Class daoClass : DaoUtils.getDaoClasses()) {
-      container.addSingleton(daoClass);
-    }
-
-    // hibernate
-    container.addSingleton(DefaultDatabaseConnector.class);
-    container.addSingleton(JpaDatabaseSession.class);
-    container.addSingleton(BatchDatabaseSessionFactory.class);
-  }
-
-  private void registerCoreTasks() {
-    container.addSingleton(ListTasksTask.class);
-  }
-
-  private void registerTaskExtensions() {
-    ExtensionInstaller installer = container.getComponentByType(ExtensionInstaller.class);
-    installer.installTaskExtensions(container, projectPresent);
-  }
-
-  private void logSettings() {
-    LOG.info("-------------  Executing {}", taskDefinition.getName());
-  }
-
-  /**
-   * Execute task
-   */
-  @Override
-  protected void doStart() {
-    Task task = container.getComponentByType(taskDefinition.getTask());
-    if (task != null) {
-      task.execute();
-    }
-    else {
-      throw new SonarException("Extension " + taskDefinition.getTask() + " was not found in declared extensions.");
-    }
-  }
-
-}
index 12c104f03bb7bcf143d9e1ed15b18a5afbd8872d..5ad891af55f5d0100e6e67a145b6fd293339c6f1 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.batch.bootstrap;
 
+import org.sonar.batch.tasks.RequiresProject;
+
 import org.sonar.api.task.TaskDefinitionExtension;
 import org.sonar.api.task.TaskExtension;
 
@@ -27,7 +29,6 @@ import org.sonar.api.BatchExtension;
 import org.sonar.api.Extension;
 import org.sonar.api.batch.InstantiationStrategy;
 import org.sonar.api.batch.SupportedEnvironment;
-import org.sonar.api.task.RequiresProject;
 import org.sonar.api.utils.AnnotationUtils;
 import org.sonar.batch.bootstrapper.EnvironmentInformation;
 import org.sonar.core.DryRunIncompatible;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectLessTaskModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectLessTaskModule.java
deleted file mode 100644 (file)
index 49c9506..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.batch.bootstrap;
-
-import org.sonar.api.task.TaskDefinition;
-
-public class ProjectLessTaskModule extends AbstractTaskModule {
-
-  public ProjectLessTaskModule(TaskDefinition task) {
-    super(task, false);
-  }
-
-  @Override
-  protected void configure() {
-    super.configure();
-  }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectTaskModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectTaskModule.java
deleted file mode 100644 (file)
index ae54002..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.batch.bootstrap;
-
-import org.sonar.api.task.TaskDefinition;
-
-import org.sonar.batch.DefaultFileLinesContextFactory;
-import org.sonar.batch.ProjectConfigurator;
-import org.sonar.batch.ProjectTree;
-import org.sonar.batch.index.DefaultIndex;
-import org.sonar.batch.tasks.InspectionTask;
-
-public class ProjectTaskModule extends AbstractTaskModule {
-
-  public ProjectTaskModule(TaskDefinition task) {
-    super(task, true);
-  }
-
-  @Override
-  protected void configure() {
-    super.configure();
-    registerCoreComponentsRequiringProject();
-    registerCoreTasksRequiringProject();
-  }
-
-  private void registerCoreComponentsRequiringProject() {
-    container.addSingleton(ProjectExclusions.class);
-    container.addSingleton(ProjectReactorReady.class);
-    container.addSingleton(ProjectTree.class);
-    container.addSingleton(ProjectConfigurator.class);
-    container.addSingleton(DefaultIndex.class);
-    container.addSingleton(DefaultFileLinesContextFactory.class);
-    container.addSingleton(ProjectLock.class);
-
-    container.addSingleton(DryRunDatabase.class);
-  }
-
-  private void registerCoreTasksRequiringProject() {
-    container.addSingleton(InspectionTask.class);
-  }
-
-}
index de57549c9619f95a942ca802ac47e8713d7afe5f..052d9a0793196d42e6c54bd639b4690980119297 100644 (file)
@@ -65,13 +65,7 @@ public class TaskBootstrapModule extends Module {
     if (ExtensionUtils.requiresProject(taskDefinition.getTask()) && !projectPresent) {
       throw new SonarException("Task " + taskDefinition.getName() + " requires to be run on a project");
     }
-    Module childModule;
-    if (projectPresent) {
-      childModule = new ProjectTaskModule(taskDefinition);
-    }
-    else {
-      childModule = new ProjectLessTaskModule(taskDefinition);
-    }
+    Module childModule = new TaskModule(taskDefinition, projectPresent);
     try {
       installChild(childModule);
       childModule.start();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskModule.java
new file mode 100644 (file)
index 0000000..1193b23
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.batch.bootstrap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.config.EmailSettings;
+import org.sonar.api.resources.ResourceTypes;
+import org.sonar.api.task.Task;
+import org.sonar.api.task.TaskDefinition;
+import org.sonar.api.utils.SonarException;
+import org.sonar.batch.DefaultFileLinesContextFactory;
+import org.sonar.batch.DefaultResourceCreationLock;
+import org.sonar.batch.ProjectConfigurator;
+import org.sonar.batch.ProjectTree;
+import org.sonar.batch.components.PastMeasuresLoader;
+import org.sonar.batch.components.PastSnapshotFinder;
+import org.sonar.batch.components.PastSnapshotFinderByDate;
+import org.sonar.batch.components.PastSnapshotFinderByDays;
+import org.sonar.batch.components.PastSnapshotFinderByPreviousAnalysis;
+import org.sonar.batch.components.PastSnapshotFinderByPreviousVersion;
+import org.sonar.batch.components.PastSnapshotFinderByVersion;
+import org.sonar.batch.index.DefaultIndex;
+import org.sonar.batch.index.DefaultPersistenceManager;
+import org.sonar.batch.index.DefaultResourcePersister;
+import org.sonar.batch.index.DependencyPersister;
+import org.sonar.batch.index.EventPersister;
+import org.sonar.batch.index.LinkPersister;
+import org.sonar.batch.index.MeasurePersister;
+import org.sonar.batch.index.MemoryOptimizer;
+import org.sonar.batch.index.SourcePersister;
+import org.sonar.batch.tasks.InspectionTask;
+import org.sonar.batch.tasks.ListTasksTask;
+import org.sonar.core.i18n.I18nManager;
+import org.sonar.core.i18n.RuleI18nManager;
+import org.sonar.core.metric.CacheMetricFinder;
+import org.sonar.core.notification.DefaultNotificationManager;
+import org.sonar.core.persistence.DaoUtils;
+import org.sonar.core.persistence.DatabaseVersion;
+import org.sonar.core.persistence.MyBatis;
+import org.sonar.core.persistence.SemaphoresImpl;
+import org.sonar.core.resource.DefaultResourcePermissions;
+import org.sonar.core.rule.CacheRuleFinder;
+import org.sonar.core.user.DefaultUserFinder;
+import org.sonar.jpa.dao.MeasuresDao;
+import org.sonar.jpa.session.DefaultDatabaseConnector;
+import org.sonar.jpa.session.JpaDatabaseSession;
+
+/**
+ * Level-3 components. Task-level components that don't depends on project.
+ */
+public class TaskModule extends Module {
+
+  private static final Logger LOG = LoggerFactory.getLogger(TaskModule.class);
+
+  private TaskDefinition taskDefinition;
+  private boolean projectPresent;
+
+  public TaskModule(TaskDefinition task, boolean projectPresent) {
+    this.taskDefinition = task;
+    this.projectPresent = projectPresent;
+  }
+
+  @Override
+  protected void configure() {
+    logSettings();
+    registerCoreComponents();
+    registerDatabaseComponents();
+    registerTaskExtensions();
+    registerCoreTasks();
+    if (projectPresent) {
+      registerCoreComponentsRequiringProject();
+    }
+  }
+
+  private void registerCoreComponents() {
+    container.addSingleton(EmailSettings.class);
+    container.addSingleton(I18nManager.class);
+    container.addSingleton(RuleI18nManager.class);
+    container.addSingleton(DefaultResourceCreationLock.class);
+
+    container.addSingleton(DefaultPersistenceManager.class);
+    container.addSingleton(DependencyPersister.class);
+    container.addSingleton(EventPersister.class);
+    container.addSingleton(LinkPersister.class);
+    container.addSingleton(MeasurePersister.class);
+
+    container.addSingleton(MemoryOptimizer.class);
+    container.addSingleton(DefaultResourcePermissions.class);
+    container.addSingleton(DefaultResourcePersister.class);
+    container.addSingleton(SourcePersister.class);
+    container.addSingleton(MeasuresDao.class);
+    container.addSingleton(CacheRuleFinder.class);
+    container.addSingleton(CacheMetricFinder.class);
+    container.addSingleton(PastSnapshotFinderByDate.class);
+    container.addSingleton(PastSnapshotFinderByDays.class);
+    container.addSingleton(PastSnapshotFinderByPreviousAnalysis.class);
+    container.addSingleton(PastSnapshotFinderByVersion.class);
+    container.addSingleton(PastSnapshotFinderByPreviousVersion.class);
+    container.addSingleton(PastMeasuresLoader.class);
+    container.addSingleton(PastSnapshotFinder.class);
+    container.addSingleton(DefaultNotificationManager.class);
+    container.addSingleton(DefaultUserFinder.class);
+    container.addSingleton(ResourceTypes.class);
+    container.addSingleton(SemaphoresImpl.class);
+    container.addSingleton(MetricProvider.class);
+  }
+
+  private void registerDatabaseComponents() {
+    container.addSingleton(JdbcDriverHolder.class);
+    container.addSingleton(BatchDatabase.class);
+    container.addSingleton(MyBatis.class);
+    container.addSingleton(DatabaseVersion.class);
+    container.addSingleton(DatabaseCompatibility.class);
+    for (Class daoClass : DaoUtils.getDaoClasses()) {
+      container.addSingleton(daoClass);
+    }
+
+    // hibernate
+    container.addSingleton(DefaultDatabaseConnector.class);
+    container.addSingleton(JpaDatabaseSession.class);
+    container.addSingleton(BatchDatabaseSessionFactory.class);
+  }
+
+  private void registerCoreTasks() {
+    container.addSingleton(ListTasksTask.class);
+    if (projectPresent) {
+      container.addSingleton(InspectionTask.class);
+    }
+  }
+
+  private void registerTaskExtensions() {
+    ExtensionInstaller installer = container.getComponentByType(ExtensionInstaller.class);
+    installer.installTaskExtensions(container, projectPresent);
+  }
+
+  private void registerCoreComponentsRequiringProject() {
+    container.addSingleton(ProjectExclusions.class);
+    container.addSingleton(ProjectReactorReady.class);
+    container.addSingleton(ProjectTree.class);
+    container.addSingleton(ProjectConfigurator.class);
+    container.addSingleton(DefaultIndex.class);
+    container.addSingleton(DefaultFileLinesContextFactory.class);
+    container.addSingleton(ProjectLock.class);
+
+    container.addSingleton(DryRunDatabase.class);
+  }
+
+  private void logSettings() {
+    LOG.info("-------------  Executing {}", taskDefinition.getName());
+  }
+
+  /**
+   * Execute task
+   */
+  @Override
+  protected void doStart() {
+    Task task = container.getComponentByType(taskDefinition.getTask());
+    if (task != null) {
+      task.execute();
+    }
+    else {
+      throw new SonarException("Extension " + taskDefinition.getTask() + " was not found in declared extensions.");
+    }
+  }
+
+}
index 05ead3d88c8b6e63d8a95079eb47b75864124868..a98a960a50b1786a402499a5a946f2b94cbc4c6a 100644 (file)
@@ -23,7 +23,6 @@ import org.sonar.batch.bootstrap.InspectionModule;
 
 import org.sonar.api.platform.ComponentContainer;
 import org.sonar.api.resources.Project;
-import org.sonar.api.task.RequiresProject;
 import org.sonar.api.task.Task;
 import org.sonar.api.task.TaskDefinition;
 import org.sonar.batch.ProjectTree;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/tasks/RequiresProject.java b/sonar-batch/src/main/java/org/sonar/batch/tasks/RequiresProject.java
new file mode 100644 (file)
index 0000000..430a53d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.batch.tasks;
+
+import com.google.common.annotations.Beta;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * The presence of this annotation on a task extension class indicates that the extension
+ * will be disabled when there is no project available.
+ *
+ * @since 3.5
+ */
+@Beta
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface RequiresProject {
+}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/AbstractTaskModuleTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/AbstractTaskModuleTest.java
deleted file mode 100644 (file)
index 4963c9c..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.batch.bootstrap;
-
-import org.junit.Test;
-import org.sonar.api.platform.ComponentContainer;
-import org.sonar.api.task.TaskDefinition;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class AbstractTaskModuleTest {
-  @Test
-  public void should_register_task_extensions_when_project_present() {
-    final ExtensionInstaller extensionInstaller = mock(ExtensionInstaller.class);
-    Module bootstrapModule = new Module() {
-      @Override
-      protected void configure() {
-        // used to install project extensions
-        container.addSingleton(extensionInstaller);
-      }
-    };
-    bootstrapModule.init();
-    ProjectTaskModule module = new ProjectTaskModule(TaskDefinition.create());
-    bootstrapModule.installChild(module);
-
-    verify(extensionInstaller).installTaskExtensions(any(ComponentContainer.class), eq(true));
-  }
-
-  @Test
-  public void should_register_task_extensions_when_no_project() {
-    final ExtensionInstaller extensionInstaller = mock(ExtensionInstaller.class);
-    Module bootstrapModule = new Module() {
-      @Override
-      protected void configure() {
-        // used to install project extensions
-        container.addSingleton(extensionInstaller);
-      }
-    };
-    bootstrapModule.init();
-    ProjectLessTaskModule module = new ProjectLessTaskModule(TaskDefinition.create());
-    bootstrapModule.installChild(module);
-
-    verify(extensionInstaller).installTaskExtensions(any(ComponentContainer.class), eq(false));
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskModuleTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskModuleTest.java
new file mode 100644 (file)
index 0000000..e5b7f49
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.batch.bootstrap;
+
+import org.junit.Test;
+import org.sonar.api.platform.ComponentContainer;
+import org.sonar.api.task.TaskDefinition;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class TaskModuleTest {
+  @Test
+  public void should_register_task_extensions_when_project_present() {
+    final ExtensionInstaller extensionInstaller = mock(ExtensionInstaller.class);
+    Module bootstrapModule = new Module() {
+      @Override
+      protected void configure() {
+        // used to install project extensions
+        container.addSingleton(extensionInstaller);
+      }
+    };
+    bootstrapModule.init();
+    TaskModule module = new TaskModule(TaskDefinition.create(), true);
+    bootstrapModule.installChild(module);
+
+    verify(extensionInstaller).installTaskExtensions(any(ComponentContainer.class), eq(true));
+  }
+
+  @Test
+  public void should_register_task_extensions_when_no_project() {
+    final ExtensionInstaller extensionInstaller = mock(ExtensionInstaller.class);
+    Module bootstrapModule = new Module() {
+      @Override
+      protected void configure() {
+        // used to install project extensions
+        container.addSingleton(extensionInstaller);
+      }
+    };
+    bootstrapModule.init();
+    TaskModule module = new TaskModule(TaskDefinition.create(), false);
+    bootstrapModule.installChild(module);
+
+    verify(extensionInstaller).installTaskExtensions(any(ComponentContainer.class), eq(false));
+  }
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/task/RequiresProject.java b/sonar-plugin-api/src/main/java/org/sonar/api/task/RequiresProject.java
deleted file mode 100644 (file)
index 23f1e52..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.task;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * The presence of this annotation on a task extension class indicates that the extension
- * will be disabled when there is no project available.
- *
- * @since 3.5
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface RequiresProject {
-}