diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-02-04 02:46:42 +0300 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-02-05 02:58:16 +0300 |
commit | 3b51f04bd4d3b16957823f7e84a58375039c9540 (patch) | |
tree | 4fd443083d96c0f38a4711d95ed57087b52c0a1f /sonar-plugin-api/src | |
parent | 04407c6b384ee7ec9ecdcc33485d7a6ef05c3026 (diff) | |
download | sonarqube-3b51f04bd4d3b16957823f7e84a58375039c9540.tar.gz sonarqube-3b51f04bd4d3b16957823f7e84a58375039c9540.zip |
SONAR-2172: New extension point - AbstractInitializer
* Mark interface DependsUponMavenPlugin by annotation
SupportedEnvironment with value "maven"
* Extract CoberturaMavenInitializer from CoberturaSensor
* Extract CloverMavenInitializer from CloverSensor
Diffstat (limited to 'sonar-plugin-api/src')
3 files changed, 52 insertions, 3 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractInitializer.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractInitializer.java new file mode 100644 index 00000000000..9c34f2869c9 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractInitializer.java @@ -0,0 +1,46 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 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.batch; + +import org.sonar.api.batch.Phase.Name; +import org.sonar.api.resources.Project; + +/** + * @since 2.6 + */ +@Phase(name = Name.PRE) +public abstract class AbstractInitializer implements Sensor { + + public boolean shouldExecuteOnProject(Project project) { + return true; + } + + public void analyse(Project project, SensorContext context) { + prepare(project); + } + + public abstract void prepare(Project project); + + @Override + public String toString() { + return getClass().getSimpleName(); + } + +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SupportedEnvironment.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SupportedEnvironment.java index 7862c224b29..5a120ebbbe3 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SupportedEnvironment.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SupportedEnvironment.java @@ -26,8 +26,9 @@ import java.lang.annotation.Target; /** * This annotation allows to specify in which environments {@link org.sonar.api.BatchExtension} would be active. - * Consult to {@link org.sonar.api.platform.Environment} to find possible values, for example - "maven2". - * We strictly recommend you to not overuse this annotation - most preferable is to design extensions to work in all environments. + * For example: "maven", "ant". + * Usage of this annotation is discouraged and we strictly recommend you to not overuse it. + * Most preferable is to design extensions to work in all environments. * * @since 2.6 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/maven/DependsUponMavenPlugin.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/maven/DependsUponMavenPlugin.java index 26e69a20f43..11ea8d00f75 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/maven/DependsUponMavenPlugin.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/maven/DependsUponMavenPlugin.java @@ -20,13 +20,15 @@ package org.sonar.api.batch.maven; import org.sonar.api.BatchExtension; +import org.sonar.api.batch.SupportedEnvironment; import org.sonar.api.resources.Project; /** * Used for Sensors and PostJobs only. - * + * * @since 1.10 */ +@SupportedEnvironment("maven") public interface DependsUponMavenPlugin extends BatchExtension { MavenPluginHandler getMavenPluginHandler(Project project); |