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