001/* 002 * SonarQube 003 * Copyright (C) 2009-2016 SonarSource SA 004 * mailto:contact AT sonarsource DOT com 005 * 006 * This program 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 * This program 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 License 017 * along with this program; if not, write to the Free Software Foundation, 018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 */ 020package org.sonar.api.ce.posttask; 021 022import java.util.Date; 023import java.util.Optional; 024import javax.annotation.CheckForNull; 025import org.sonar.api.ExtensionPoint; 026import org.sonar.api.ce.ComputeEngineSide; 027 028/** 029 * Extension point of which any plugin can provide an implementation and will allow them to be notified whenever some 030 * analysis report processing ends in the Compute Engine. 031 * 032 * <p> 033 * If more then one implementation of {@link PostProjectAnalysisTask} is found, they will be executed in no specific order. 034 * 035 * 036 * <p> 037 * Class {@link PostProjectAnalysisTaskTester} is provided to write unit tests of implementations of this interface. 038 * 039 * 040 * @since 5.5 041 * @see PostProjectAnalysisTaskTester 042 */ 043@ExtensionPoint 044@ComputeEngineSide 045public interface PostProjectAnalysisTask { 046 /** 047 * This method is called whenever the processing of a Project analysis has finished, whether successfully or not. 048 */ 049 void finished(ProjectAnalysis analysis); 050 051 /** 052 * @since 5.5 053 */ 054 interface ProjectAnalysis { 055 /** 056 * Details of the Compute Engine task in which the project analysis was run. 057 */ 058 CeTask getCeTask(); 059 060 /** 061 * Details of the analyzed project. 062 */ 063 Project getProject(); 064 065 /** 066 * Status and details of the Quality Gate of the project (if any was configured on the project). 067 */ 068 @CheckForNull 069 QualityGate getQualityGate(); 070 071 /** 072 * Date of the analysis. 073 * <p> 074 * This date is the same as the date of the project analysis report and the snapshot. 075 * 076 * @deprecated use {@link #getAnalysisDate()} instead. When {@link #getAnalysisDate()} returns 077 * {@link Optional#empty() empty}, the current date will be returned. 078 */ 079 @Deprecated 080 Date getDate(); 081 082 /** 083 * Date of the analysis. 084 * <p> 085 * This date is the same as the date of the project analysis report and therefore as the analysis in DB. It can be 086 * missing when the status of the task is {@link org.sonar.api.ce.posttask.CeTask.Status#FAILED FAILED}. 087 * </p> 088 */ 089 Optional<Date> getAnalysisDate(); 090 091 /** 092 * Context as defined by scanner through {@link org.sonar.api.batch.sensor.SensorContext#addContextProperty(String, String)}. 093 * It does not contain the settings used by scanner. 094 * 095 * @since 6.1 096 */ 097 ScannerContext getScannerContext(); 098 } 099}