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.batch.bootstrap;
021
022import org.sonar.api.ExtensionPoint;
023import org.sonar.api.batch.InstantiationStrategy;
024import org.sonar.api.batch.ScannerSide;
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@ScannerSide
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   * @since 3.7
053   */
054  protected ProjectBuilder() {
055  }
056
057  /**
058   * Override this method to change project reactor structure.
059   * @since 3.7
060   */
061  public void build(Context context) {
062    // Call deprecated method for backward compatibility
063    build(context.projectReactor());
064  }
065
066  /**
067   * @deprecated since 3.7 override {@link #build(Context)} instead
068   */
069  @Deprecated
070  protected void build(ProjectReactor reactor) {
071  }
072}