001 /*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2009 SonarSource SA
004 * mailto:contact AT sonarsource DOT com
005 *
006 * Sonar is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * Sonar is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with Sonar; if not, write to the Free Software
018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
019 */
020 package org.sonar.api.batch;
021
022 import org.sonar.api.BatchExtension;
023 import org.sonar.api.resources.Project;
024
025 /**
026 * <p>A Sensor is invoked once during the analysis of a project. The sensor can invoke a maven plugin,
027 * parse a flat file, connect to a web server... For example the Cobertura Sensor invokes the Codehaus Cobertura MOJO.
028 * Then the generated XML file is parsed and used to save the first-level of measures on resources
029 * (project, package or class).</p>
030 *
031 * <p>Sensors are executed first during project analysis. Sensor are generally used to add measure at the
032 * lowest level of the resource tree. A sensor can access and save measures on the whole tree of resources.</p>
033 *
034 * <p>A particular attention should be given to resource exclusion. Sonar already manages exclusions at file level : if
035 * you try to save a measure on a resource that is excluded in the settings, then Sonar will not save the measure.
036 * When handling a plugin or an external tool, you should make sure that exclusions are passed if you are going to get
037 * back consolidated data.</p>
038 *
039 * @since 1.10
040 */
041 public interface Sensor extends BatchExtension, CheckProject {
042
043 /**
044 * Sensors that depend upon Squid must declare the following method :
045 * <code>
046 *
047 * @DependsUpon public String dependsUponSquidAnalysis() {
048 * return Sensor.FLAG_SQUID_ANALYSIS;
049 * }
050 * </code>
051 * }
052 */
053 String FLAG_SQUID_ANALYSIS = "squid";
054
055 /**
056 * The method that is going to be run when the sensor is called
057 *
058 * @param project the project the sensor runs on
059 * @param context the context
060 */
061 void analyse(Project project, SensorContext context);
062
063 }