001/* 002 * SonarQube 003 * Copyright (C) 2009-2017 SonarSource SA 004 * mailto:info 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 * The branch that is being analyzed. 067 * 068 * @since 6.6 069 */ 070 Optional<Branch> getBranch(); 071 072 /** 073 * Status and details of the Quality Gate of the project (if any was configured on the project). 074 */ 075 @CheckForNull 076 QualityGate getQualityGate(); 077 078 /** 079 * Date of the analysis. 080 * <p> 081 * This date is the same as the date of the project analysis report and the snapshot. 082 * 083 * @deprecated use {@link #getAnalysisDate()} instead. When {@link #getAnalysisDate()} returns 084 * {@link Optional#empty() empty}, the current date will be returned. 085 */ 086 @Deprecated 087 Date getDate(); 088 089 /** 090 * Date of the analysis. 091 * <p> 092 * This date is the same as the date of the project analysis report and therefore as the analysis in DB. It can be 093 * missing when the status of the task is {@link org.sonar.api.ce.posttask.CeTask.Status#FAILED FAILED}. 094 * </p> 095 */ 096 Optional<Date> getAnalysisDate(); 097 098 /** 099 * Context as defined by scanner through {@link org.sonar.api.batch.sensor.SensorContext#addContextProperty(String, String)}. 100 * It does not contain the settings used by scanner. 101 * 102 * @since 6.1 103 */ 104 ScannerContext getScannerContext(); 105 } 106}