001/*
002 * Copyright (C) 2022 - 2024, 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 java.util.Set;
020import org.apiguardian.api.API;
021import org.apiguardian.api.API.Status;
022import org.jspecify.annotations.Nullable;
023
024/**
025 * Interface for defining a common flag builder for compilers.
026 *
027 * @author Ashley Scopes
028 */
029@API(since = "0.0.1", status = Status.STABLE)
030public interface JctFlagBuilder {
031
032  /**
033   * Add output-verbosity preferences.
034   *
035   * @param enabled whether the feature is enabled.
036   * @return this builder.
037   */
038  JctFlagBuilder verbose(boolean enabled);
039
040  /**
041   * Add preview feature preferences.
042   *
043   * @param enabled whether the feature is enabled.
044   * @return this builder.
045   */
046  JctFlagBuilder previewFeatures(boolean enabled);
047
048  /**
049   * Add warnings preferences.
050   *
051   * @param enabled whether the feature is enabled.
052   * @return this builder.
053   */
054  JctFlagBuilder showWarnings(boolean enabled);
055
056  /**
057   * Set whether to treat warnings as errors or not.
058   *
059   * @param enabled whether to treat warnings as errors.
060   * @return this builder.
061   */
062  JctFlagBuilder failOnWarnings(boolean enabled);
063
064  /**
065   * Set the compilation mode to run under.
066   *
067   * @param compilationMode the compilation mode to run under.
068   * @return this builder.
069   */
070  JctFlagBuilder compilationMode(CompilationMode compilationMode);
071
072  /**
073   * Add deprecation warning preferences.
074   *
075   * @param enabled whether the feature is enabled.
076   * @return this builder.
077   */
078  JctFlagBuilder showDeprecationWarnings(boolean enabled);
079
080  /**
081   * Add the release version.
082   *
083   * @param version the release version, or {@code null} if not specified.
084   * @return this builder.
085   */
086  JctFlagBuilder release(@Nullable String version);
087
088  /**
089   * Add the source version.
090   *
091   * @param version the source version, or {@code null} if not specified.
092   * @return this builder.
093   */
094  JctFlagBuilder source(@Nullable String version);
095
096  /**
097   * Add the target version.
098   *
099   * @param version the target version, or {@code null} if not specified.
100   * @return this builder.
101   */
102  JctFlagBuilder target(@Nullable String version);
103
104  /**
105   * Add the debugging info flags.
106   *
107   * @param set the set of debugging info flags to enable.
108   * @return this builder.
109   * @since 3.0.0
110   */
111  JctFlagBuilder debuggingInfo(Set<DebuggingInfo> set);
112
113  /**
114   * Specify whether to include parameter reflection info in the compiled classes.
115   *
116   * @param enabled whether the parameter info is enabled or not.
117   * @return this builder.
118   * @since 3.0.0
119   */
120  JctFlagBuilder parameterInfoEnabled(boolean enabled);
121
122  /**
123   * Add annotation processor options.
124   *
125   * @param options the annotation processor options to use.
126   * @return this builder.
127   */
128  JctFlagBuilder annotationProcessorOptions(List<String> options);
129
130  /**
131   * Add additional command line options.
132   *
133   * @param options the additional commandline options to add.
134   * @return this builder.
135   */
136  JctFlagBuilder compilerOptions(List<String> options);
137
138  /**
139   * Build the list of command line options to use.
140   *
141   * @return the command line options to use.
142   */
143  List<String> build();
144}