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.batch.bootstrap; 021 022import org.sonar.api.batch.BatchSide; 023import org.sonar.api.ExtensionPoint; 024import org.sonar.api.batch.InstantiationStrategy; 025 026/** 027 * This extension point allows to change project structure at runtime. It is executed once during task startup. 028 * Some use-cases : 029 * <ul> 030 * <li>Add sub-projects. For example the C# plugin gets the hierarchy 031 * of sub-projects from the Visual Studio metadata file. The single root pom.xml does not contain any declarations of 032 * modules</li> 033 * <li>Change project metadata like description or source directories.</li> 034 * </ul> 035 * 036 * @since 2.9 037 */ 038@BatchSide 039@InstantiationStrategy(InstantiationStrategy.PER_BATCH) 040@ExtensionPoint 041public abstract class ProjectBuilder { 042 043 /** 044 * Plugins can use the implementation {@link org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext} 045 * for their unit tests. 046 */ 047 public interface Context { 048 ProjectReactor projectReactor(); 049 } 050 051 /** 052 * Don't inject ProjectReactor as it may not be available 053 * @deprecated since 3.7 use {@link #ProjectBuilder()} 054 */ 055 @Deprecated 056 protected ProjectBuilder(final ProjectReactor reactor) { 057 } 058 059 /** 060 * @since 3.7 061 */ 062 protected ProjectBuilder() { 063 } 064 065 /** 066 * Override this method to change project reactor structure. 067 * @since 3.7 068 */ 069 public void build(Context context) { 070 // Call deprecated method for backward compatibility 071 build(context.projectReactor()); 072 } 073 074 /** 075 * @deprecated since 3.7 override {@link #build(Context)} instead 076 */ 077 @Deprecated 078 protected void build(ProjectReactor reactor) { 079 } 080}