001/*
002 * Copyright (C) 2022 - 2023, the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *    http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package io.github.ascopes.jct.compilers;
017
018import java.util.List;
019import org.apiguardian.api.API;
020import org.apiguardian.api.API.Status;
021import org.jspecify.annotations.Nullable;
022
023/**
024 * Interface for defining a common flag builder for compilers.
025 *
026 * @author Ashley Scopes
027 */
028@API(since = "0.0.1", status = Status.STABLE)
029public interface JctFlagBuilder {
030
031  /**
032   * Add output-verbosity preferences.
033   *
034   * @param enabled whether the feature is enabled.
035   * @return this builder.
036   */
037  JctFlagBuilder verbose(boolean enabled);
038
039  /**
040   * Add preview feature preferences.
041   *
042   * @param enabled whether the feature is enabled.
043   * @return this builder.
044   */
045  JctFlagBuilder previewFeatures(boolean enabled);
046
047  /**
048   * Add warnings preferences.
049   *
050   * @param enabled whether the feature is enabled.
051   * @return this builder.
052   */
053  JctFlagBuilder showWarnings(boolean enabled);
054
055  /**
056   * Set whether to treat warnings as errors or not.
057   *
058   * @param enabled whether to treat warnings as errors.
059   * @return this builder.
060   */
061  JctFlagBuilder failOnWarnings(boolean enabled);
062
063  /**
064   * Set the compilation mode to run under.
065   *
066   * @param compilationMode the compilation mode to run under.
067   * @return this builder.
068   */
069  JctFlagBuilder compilationMode(CompilationMode compilationMode);
070
071  /**
072   * Add deprecation warning preferences.
073   *
074   * @param enabled whether the feature is enabled.
075   * @return this builder.
076   */
077  JctFlagBuilder showDeprecationWarnings(boolean enabled);
078
079  /**
080   * Add the release version.
081   *
082   * @param version the release version, or {@code null} if not specified.
083   * @return this builder.
084   */
085  JctFlagBuilder release(@Nullable String version);
086
087  /**
088   * Add the source version.
089   *
090   * @param version the source version, or {@code null} if not specified.
091   * @return this builder.
092   */
093  JctFlagBuilder source(@Nullable String version);
094
095  /**
096   * Add the target version.
097   *
098   * @param version the target version, or {@code null} if not specified.
099   * @return this builder.
100   */
101  JctFlagBuilder target(@Nullable String version);
102
103  /**
104   * Add annotation processor options.
105   *
106   * @param options the annotation processor options to use.
107   * @return this builder.
108   */
109  JctFlagBuilder annotationProcessorOptions(List<String> options);
110
111  /**
112   * Add additional command line options.
113   *
114   * @param options the additional commandline options to add.
115   * @return this builder.
116   */
117  JctFlagBuilder compilerOptions(List<String> options);
118
119  /**
120   * Build the list of command line options to use.
121   *
122   * @return the command line options to use.
123   */
124  List<String> build();
125}