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 io.github.ascopes.jct.ex.JctCompilerException;
019import io.github.ascopes.jct.filemanagers.AnnotationProcessorDiscovery;
020import io.github.ascopes.jct.filemanagers.LoggingMode;
021import io.github.ascopes.jct.utils.IterableUtils;
022import io.github.ascopes.jct.workspaces.Workspace;
023import java.io.UncheckedIOException;
024import java.nio.charset.Charset;
025import java.nio.charset.StandardCharsets;
026import java.util.Collection;
027import java.util.List;
028import java.util.Locale;
029import javax.annotation.processing.Processor;
030import javax.lang.model.SourceVersion;
031import org.apiguardian.api.API;
032import org.apiguardian.api.API.Status;
033
034/**
035 * Base definition of a compiler that can be configured to perform a compilation run against
036 * sources. This is designed to provide functionality that {@code javac} does by default, for JDK
037 * 17.
038 *
039 * @author Ashley Scopes
040 * @since 0.0.1
041 */
042@API(since = "0.0.1", status = Status.STABLE)
043public interface JctCompiler {
044
045  /**
046   * Default setting for deprecation warnings ({@code true}).
047   */
048  boolean DEFAULT_SHOW_DEPRECATION_WARNINGS = true;
049
050  /**
051   * Default setting for locale ({@link Locale#ROOT}).
052   */
053  Locale DEFAULT_LOCALE = Locale.ROOT;
054
055  /**
056   * Default setting for preview features ({@code false}).
057   */
058  boolean DEFAULT_PREVIEW_FEATURES = false;
059
060  /**
061   * Default setting for verbose logging ({@code false}).
062   */
063  boolean DEFAULT_VERBOSE = false;
064
065  /**
066   * Default setting for displaying warnings ({@code true}).
067   */
068  boolean DEFAULT_SHOW_WARNINGS = true;
069
070  /**
071   * Default setting for displaying warnings as errors ({@code false}).
072   */
073  boolean DEFAULT_FAIL_ON_WARNINGS = false;
074
075  /**
076   * Default setting for fixing modules being placed on the classpath by mistake ({@code true}).
077   */
078  boolean DEFAULT_FIX_JVM_MODULE_PATH_MISMATCH = true;
079
080  /**
081   * Default setting for inclusion of the current class path ({@code true}).
082   */
083  boolean DEFAULT_INHERIT_CLASS_PATH = true;
084
085  /**
086   * Default setting for inclusion of the current module path ({@code true}).
087   */
088  boolean DEFAULT_INHERIT_MODULE_PATH = true;
089
090  /**
091   * Default setting for inclusion of the system module path ({@code true}).
092   */
093  boolean DEFAULT_INHERIT_SYSTEM_MODULE_PATH = true;
094
095  /**
096   * Default setting for logging file manager operations ({@link LoggingMode#DISABLED}).
097   */
098  LoggingMode DEFAULT_FILE_MANAGER_LOGGING_MODE = LoggingMode.DISABLED;
099
100  /**
101   * Default setting for logging diagnostics ({@link LoggingMode#ENABLED}).
102   */
103  LoggingMode DEFAULT_DIAGNOSTIC_LOGGING_MODE = LoggingMode.ENABLED;
104
105  /**
106   * Default setting for the compilation mode to use
107   * ({@link CompilationMode#COMPILATION_AND_ANNOTATION_PROCESSING}).
108   */
109  CompilationMode DEFAULT_COMPILATION_MODE = CompilationMode.COMPILATION_AND_ANNOTATION_PROCESSING;
110
111  /**
112   * Default setting for how to apply annotation processor discovery when no processors are
113   * explicitly defined ({@link AnnotationProcessorDiscovery#INCLUDE_DEPENDENCIES}).
114   */
115  AnnotationProcessorDiscovery DEFAULT_ANNOTATION_PROCESSOR_DISCOVERY =
116      AnnotationProcessorDiscovery.INCLUDE_DEPENDENCIES;
117
118  /**
119   * Default charset to use for compiler logs ({@link StandardCharsets#UTF_8}).
120   */
121  Charset DEFAULT_LOG_CHARSET = StandardCharsets.UTF_8;
122
123  /**
124   * Invoke the compilation and return the compilation result.
125   *
126   * <p>The actual classes to compile will be dynamically discovered. If you wish to
127   * specify the specific classes to compile, see {@link #compile(Workspace, String, String...)} or
128   * {@link #compile(Workspace, Collection)}.
129   *
130   * @param workspace the workspace to compile.
131   * @return the compilation result.
132   * @throws JctCompilerException  if the compiler threw an unhandled exception. This should not
133   *                               occur for compilation failures generally.
134   * @throws IllegalStateException if no compilation units were found.
135   * @throws UncheckedIOException  if an IO error occurs.
136   * @see #compile(Workspace, String, String...)
137   * @see #compile(Workspace, Collection)
138   */
139  JctCompilation compile(Workspace workspace);
140
141  /**
142   * Invoke the compilation and return the compilation result.
143   *
144   * <p>Only classes matching the given class names will be compiled.
145   *
146   * <p>If you wish to let JCT determine which classes to compile dynamically, see
147   * {@link #compile(Workspace)} instead.
148   *
149   * @param workspace            the workspace to compile.
150   * @param firstClassName       the first class name to compile.
151   * @param additionalClassNames any additional class names to compile.
152   * @return the compilation result.
153   * @throws JctCompilerException  if the compiler threw an unhandled exception. This should not
154   *                               occur for compilation failures generally.
155   * @throws IllegalStateException if no compilation units were found.
156   * @throws UncheckedIOException  if an IO error occurs.
157   * @see #compile(Workspace)
158   * @see #compile(Workspace, Collection)
159   */
160  default JctCompilation compile(Workspace workspace, String firstClassName, String... additionalClassNames) {
161    return compile(workspace, IterableUtils.combineOneOrMore(firstClassName, additionalClassNames));
162  }
163
164  /**
165   * Invoke the compilation and return the compilation result.
166   *
167   * <p>Only classes matching the given class names will be compiled.
168   *
169   * <p>If you wish to let JCT determine which classes to compile dynamically, see
170   * {@link #compile(Workspace)} instead.
171   *
172   * @param workspace  the workspace to compile.
173   * @param classNames the class names to compile.
174   * @return the compilation result.
175   * @throws JctCompilerException     if the compiler threw an unhandled exception. This should not
176   *                                  occur for compilation failures generally.
177   * @throws IllegalArgumentException if the collection is empty.
178   * @throws IllegalStateException    if no compilation units were found.
179   * @throws UncheckedIOException     if an IO error occurs.
180   * @see #compile(Workspace)
181   * @see #compile(Workspace, String, String...)
182   */
183  JctCompilation compile(Workspace workspace, Collection<String> classNames);
184
185  /**
186   * Apply a given configurer to this compiler that can throw a checked exception.
187   *
188   * @param <E>        any exception that may be thrown.
189   * @param configurer the configurer to invoke.
190   * @return this compiler object for further call chaining.
191   * @throws E any exception that may be thrown by the configurer.
192   */
193  <E extends Exception> JctCompiler configure(JctCompilerConfigurer<E> configurer) throws E;
194
195  /**
196   * Get the friendly printable name of this compiler object.
197   *
198   * @return the name of the compiler.
199   */
200  String getName();
201
202  /**
203   * Set the friendly name of this compiler.
204   *
205   * @param name the name to set.
206   * @return this compiler object for further call chaining.
207   */
208  JctCompiler name(String name);
209
210  /**
211   * Get an <strong>immutable snapshot view</strong> of the current annotation processor options
212   * that are set.
213   *
214   * @return the current annotation processor options that are set.
215   */
216  List<String> getAnnotationProcessorOptions();
217
218  /**
219   * Add options to pass to any annotation processors.
220   *
221   * @param annotationProcessorOptions the options to pass.
222   * @return this compiler object for further call chaining.
223   */
224  JctCompiler addAnnotationProcessorOptions(Iterable<String> annotationProcessorOptions);
225
226  /**
227   * Add options to pass to any annotation processors.
228   *
229   * @param annotationProcessorOption  the first option to pass.
230   * @param annotationProcessorOptions additional options to pass.
231   * @return this compiler object for further call chaining.
232   */
233  default JctCompiler addAnnotationProcessorOptions(
234      String annotationProcessorOption,
235      String... annotationProcessorOptions
236  ) {
237    return addAnnotationProcessorOptions(
238        IterableUtils.combineOneOrMore(annotationProcessorOption, annotationProcessorOptions)
239    );
240  }
241
242  /**
243   * Get an <strong>immutable snapshot view</strong> of the current annotation processors that are
244   * explicitly set to be run, in the order that they were provided to the compiler.
245   *
246   * @return the current annotation processors that are set.
247   */
248  List<Processor> getAnnotationProcessors();
249
250  /**
251   * Add annotation processors to invoke.
252   *
253   * <p>This bypasses the discovery process of annotation processors provided in the annotation
254   * processor path.
255   *
256   * @param annotationProcessors the processors to invoke.
257   * @return this compiler object for further call chaining.
258   */
259  JctCompiler addAnnotationProcessors(Iterable<? extends Processor> annotationProcessors);
260
261  /**
262   * Add annotation processors to invoke.
263   *
264   * <p>This bypasses the discovery process of annotation processors provided in the annotation
265   * processor path.
266   *
267   * @param annotationProcessor  the first processor to invoke.
268   * @param annotationProcessors additional processors to invoke.
269   * @return this compiler object for further call chaining.
270   */
271  default JctCompiler addAnnotationProcessors(
272      Processor annotationProcessor,
273      Processor... annotationProcessors
274  ) {
275    return addAnnotationProcessors(
276        IterableUtils.combineOneOrMore(annotationProcessor, annotationProcessors));
277  }
278
279  /**
280   * Get an <strong>immutable snapshot view</strong> of the current compiler options that are set.
281   *
282   * @return the current compiler  options that are set.
283   */
284  List<String> getCompilerOptions();
285
286  /**
287   * Add command line options to pass to {@code javac}.
288   *
289   * @param compilerOptions the options to add.
290   * @return this compiler object for further call chaining.
291   */
292  JctCompiler addCompilerOptions(Iterable<String> compilerOptions);
293
294  /**
295   * Add command line options to pass to {@code javac}.
296   *
297   * @param compilerOption  the first option to add.
298   * @param compilerOptions additional options to add.
299   * @return this compiler object for further call chaining.
300   */
301  default JctCompiler addCompilerOptions(String compilerOption, String... compilerOptions) {
302    return addCompilerOptions(IterableUtils.combineOneOrMore(compilerOption, compilerOptions));
303  }
304
305  /**
306   * Determine whether verbose logging is enabled or not.
307   *
308   * <p>Unless otherwise changed or specified, implementations should default to
309   * {@link #DEFAULT_VERBOSE}.
310   *
311   * <p>Note that enabling this is compiler-specific behaviour. There is no guarantee that the
312   * output target or the format or verbosity of output will be consistent between different
313   * compiler implementations.
314   *
315   * @return whether verbose logging is enabled or not.
316   */
317  boolean isVerbose();
318
319  /**
320   * Set whether to use verbose output or not.
321   *
322   * <p>Unless otherwise changed or specified, implementations should default to
323   * {@link #DEFAULT_VERBOSE}.
324   *
325   * <p>Note that enabling this is compiler-specific behaviour. There is no guarantee that the
326   * output target or the format or verbosity of output will be consistent between different
327   * compiler implementations.
328   *
329   * @param enabled {@code true} for verbose output, {@code false} for normal output.
330   * @return this compiler for further call chaining.
331   */
332  JctCompiler verbose(boolean enabled);
333
334  /**
335   * Determine whether preview features are enabled or not.
336   *
337   * <p>Unless otherwise changed or specified, implementations should default to
338   * {@link #DEFAULT_PREVIEW_FEATURES}.
339   *
340   * @return whether preview features are enabled or not.
341   */
342  boolean isPreviewFeatures();
343
344  /**
345   * Set whether to enable preview features or not.
346   *
347   * <p>Unless otherwise changed or specified, implementations should default to
348   * {@link #DEFAULT_PREVIEW_FEATURES}.
349   *
350   * @param enabled {@code true} to enable preview features, or {@code false} to disable them.
351   * @return this compiler object for further call chaining.
352   */
353  JctCompiler previewFeatures(boolean enabled);
354
355  /**
356   * Determine whether warnings are enabled or not.
357   *
358   * <p>Unless otherwise changed or specified, implementations should default to
359   * {@link #DEFAULT_SHOW_WARNINGS}.
360   *
361   * @return whether warnings are enabled or not.
362   */
363  boolean isShowWarnings();
364
365  /**
366   * Set whether to enable displaying warnings or not.
367   *
368   * <p>Unless otherwise changed or specified, implementations should default to
369   * {@link #DEFAULT_SHOW_WARNINGS}.
370   *
371   * @param enabled {@code true} to enable warnings. {@code false} to disable them.
372   * @return this compiler object for further call chaining.
373   */
374  JctCompiler showWarnings(boolean enabled);
375
376  /**
377   * Determine whether deprecation warnings are enabled or not.
378   *
379   * <p>Unless otherwise changed or specified, implementations should default to
380   * {@link #DEFAULT_SHOW_DEPRECATION_WARNINGS}.
381   *
382   * @return whether deprecation warnings are enabled or not.
383   */
384  boolean isShowDeprecationWarnings();
385
386  /**
387   * Set whether to enable deprecation warnings or not.
388   *
389   * <p>This is ignored if {@link #showWarnings(boolean)} is disabled.
390   *
391   * <p>Unless otherwise changed or specified, implementations should default to
392   * {@link #DEFAULT_SHOW_DEPRECATION_WARNINGS}.
393   *
394   * @param enabled {@code true} to enable deprecation warnings. {@code false} to disable them.
395   * @return this compiler object for further call chaining.
396   */
397  JctCompiler showDeprecationWarnings(boolean enabled);
398
399  /**
400   * Determine whether warnings are being treated as errors or not.
401   *
402   * <p>Unless otherwise changed or specified, implementations should default to
403   * {@link #DEFAULT_FAIL_ON_WARNINGS}.
404   *
405   * @return whether warnings are being treated as errors or not.
406   */
407  boolean isFailOnWarnings();
408
409  /**
410   * Set whether to enable treating warnings as errors or not.
411   *
412   * <p>This is ignored if {@link #showWarnings(boolean)} is disabled.
413   *
414   * <p>Unless otherwise changed or specified, implementations should default to
415   * {@link #DEFAULT_FAIL_ON_WARNINGS}.
416   *
417   * @param enabled {@code true} to enable treating warnings as errors. {@code false} to disable
418   *                them.
419   * @return this compiler object for further call chaining.
420   */
421  JctCompiler failOnWarnings(boolean enabled);
422
423  /**
424   * Get the compilation mode that is in use.
425   *
426   * <p>Unless otherwise changed or specified, implementations should default to
427   * {@link #DEFAULT_COMPILATION_MODE}.
428   *
429   * @return the compilation mode.
430   */
431  CompilationMode getCompilationMode();
432
433  /**
434   * Set the compilation mode to use for this compiler.
435   *
436   * <p>Unless otherwise changed or specified, implementations should default to
437   * {@link #DEFAULT_COMPILATION_MODE}.
438   *
439   * @param compilationMode the compilation mode to use.
440   * @return this compiler object for further call chaining.
441   */
442  JctCompiler compilationMode(CompilationMode compilationMode);
443
444  /**
445   * Get the default release to use if no release or target version is specified.
446   *
447   * <p>This can <strong>not</strong> be configured.
448   *
449   * @return the default release version to use.
450   */
451  String getDefaultRelease();
452
453  /**
454   * Get the effective release to use for the actual compilation.
455   *
456   * <p>This may be determined from the {@link #getSource() source},
457   * {@link #getTarget() target}, {@link #getRelease() release}, and
458   * {@link #getDefaultRelease() default release.}
459   *
460   * @return the effective release.
461   */
462  String getEffectiveRelease();
463
464  /**
465   * Get the current release version that is set, or {@code null} if left to the compiler to decide.
466   * default.
467   *
468   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
469   * default.
470   *
471   * @return the release version string, if set.
472   */
473  String getRelease();
474
475  /**
476   * Set the release version.
477   *
478   * <p>This will clear any source and target version that is set.
479   *
480   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
481   * default.
482   *
483   * @param release the version to set.
484   * @return this compiler object for further call chaining.
485   */
486  JctCompiler release(String release);
487
488  /**
489   * Set the release version.
490   *
491   * <p>This will clear any source and target version that is set.
492   *
493   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
494   * default.
495   *
496   * @param release the version to set.
497   * @return this compiler object for further call chaining.
498   */
499  default JctCompiler release(int release) {
500    if (release < 0) {
501      throw new IllegalArgumentException("Cannot provide a release version less than 0");
502    }
503
504    return release(Integer.toString(release));
505  }
506
507  /**
508   * Set the release version.
509   *
510   * <p>This will clear any source and target version that is set.
511   *
512   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
513   * default.
514   *
515   * @param release the version to set.
516   * @return this compiler object for further call chaining.
517   */
518  default JctCompiler release(SourceVersion release) {
519    return release(Integer.toString(release.ordinal()));
520  }
521
522  /**
523   * Get the current source version that is set, or {@code null} if left to the compiler to decide.
524   * default.
525   *
526   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
527   * default.
528   *
529   * @return the source version string, if set.
530   */
531  String getSource();
532
533  /**
534   * Set the source version.
535   *
536   * <p>This will clear any release version that is set.
537   *
538   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
539   * default.
540   *
541   * @param source the version to set.
542   * @return this compiler object for further call chaining.
543   */
544  JctCompiler source(String source);
545
546  /**
547   * Set the source version.
548   *
549   * <p>This will clear any release version that is set.
550   *
551   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
552   * default.
553   *
554   * @param source the version to set.
555   * @return this compiler object for further call chaining.
556   */
557  default JctCompiler source(int source) {
558    if (source < 0) {
559      throw new IllegalArgumentException("Cannot provide a source version less than 0");
560    }
561
562    return source(Integer.toString(source));
563  }
564
565  /**
566   * Set the source version.
567   *
568   * <p>This will clear any release version that is set.
569   *
570   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
571   * default.
572   *
573   * @param source the version to set.
574   * @return this compiler object for further call chaining.
575   */
576  default JctCompiler source(SourceVersion source) {
577    return source(Integer.toString(source.ordinal()));
578  }
579
580  /**
581   * Get the current target version that is set, or {@code null} if left to the compiler default.
582   *
583   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
584   * default.
585   *
586   * @return the target version string, if set.
587   */
588  String getTarget();
589
590  /**
591   * Set the target version.
592   *
593   * <p>This will clear any release version that is set.
594   *
595   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
596   * default.
597   *
598   * @param target the version to set.
599   * @return this compiler object for further call chaining.
600   */
601  JctCompiler target(String target);
602
603  /**
604   * Set the target version.
605   *
606   * <p>This will clear any release version that is set.
607   *
608   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
609   * default.
610   *
611   * @param target the version to set.
612   * @return this compiler object for further call chaining.
613   */
614  default JctCompiler target(int target) {
615    if (target < 0) {
616      throw new IllegalArgumentException("Cannot provide a target version less than 0");
617    }
618
619    return target(Integer.toString(target));
620  }
621
622  /**
623   * Set the target version.
624   *
625   * <p>This will clear any release version that is set.
626   *
627   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
628   * default.
629   *
630   * @param target the version to set.
631   * @return this compiler object for further call chaining.
632   */
633  default JctCompiler target(SourceVersion target) {
634    return target(Integer.toString(target.ordinal()));
635  }
636
637  /**
638   * Get whether we will attempt to fix modules appearing on the classpath, or non-modules appearing
639   * on the module path.
640   *
641   * <p>This enables correct classpath and module path detection when the test pack is a module but
642   * the code being compiled in the test is not, and vice versa. We need this because many build
643   * systems decide whether to populate the {@code --module-path} flat or the {@code --classpath}
644   * with JPMS-enabled dependencies based on whether the project under compilation is a JPMS module
645   * itself.
646   *
647   * <p>This only applies if {@link #isInheritModulePath()} or {@link #isInheritClassPath()} is
648   * enabled, and only applies to the current JVM classpath and module path.
649   *
650   * <p>Unless otherwise changed or specified, implementations should default to
651   * {@link #DEFAULT_FIX_JVM_MODULE_PATH_MISMATCH}.
652   *
653   * @return {@code true} if enabled, or {@code false} if disabled.
654   */
655  boolean isFixJvmModulePathMismatch();
656
657  /**
658   * Get whether we will attempt to fix modules appearing on the classpath, or non-modules appearing
659   * on the module path.
660   *
661   * <p>Unless otherwise changed or specified, implementations should default to
662   * {@link #DEFAULT_FIX_JVM_MODULE_PATH_MISMATCH}.
663   *
664   * @param fixJvmModulePathMismatch whether to enable the mismatch fixing or not.
665   * @return this compiler object for further call chaining.
666   */
667  JctCompiler fixJvmModulePathMismatch(boolean fixJvmModulePathMismatch);
668
669  /**
670   * Get whether the class path is inherited from the caller JVM or not.
671   *
672   * <p>Unless otherwise changed or specified, implementations should default to
673   * {@link #DEFAULT_INHERIT_CLASS_PATH}.
674   *
675   * @return whether the current class path is being inherited or not.
676   */
677  boolean isInheritClassPath();
678
679  /**
680   * Set whether the class path is inherited from the caller JVM or not.
681   *
682   * <p>Unless otherwise changed or specified, implementations should default to
683   * {@link #DEFAULT_INHERIT_CLASS_PATH}.
684   *
685   * @param inheritClassPath {@code true} to include it, or {@code false} to exclude it.
686   * @return this compiler object for further call chaining.
687   */
688  JctCompiler inheritClassPath(boolean inheritClassPath);
689
690  /**
691   * Get whether the module path is inherited from the caller JVM or not.
692   *
693   * <p>Unless otherwise changed or specified, implementations should default to
694   * {@link #DEFAULT_INHERIT_MODULE_PATH}.
695   *
696   * @return whether the module path is being inherited or not.
697   */
698  boolean isInheritModulePath();
699
700  /**
701   * Set whether the module path is inherited from the caller JVM or not.
702   *
703   * <p>Unless otherwise changed or specified, implementations should default to
704   * {@link #DEFAULT_INHERIT_MODULE_PATH}.
705   *
706   * @param inheritModulePath {@code true} to include it, or {@code false} to exclude it.
707   * @return this compiler object for further call chaining.
708   */
709  JctCompiler inheritModulePath(boolean inheritModulePath);
710
711  /**
712   * Get whether the system module path is inherited from the caller JVM or not.
713   *
714   * <p>Unless otherwise changed or specified, implementations should default to
715   * {@link #DEFAULT_INHERIT_SYSTEM_MODULE_PATH}.
716   *
717   * @return whether the system module path is being inherited or not.
718   */
719  boolean isInheritSystemModulePath();
720
721  /**
722   * Set whether the system module path is inherited from the caller JVM or not.
723   *
724   * <p>Unless otherwise changed or specified, implementations should default to
725   * {@link #DEFAULT_INHERIT_SYSTEM_MODULE_PATH}.
726   *
727   * @param inheritSystemModulePath {@code true} to include it, or {@code false} to exclude it.
728   * @return this compiler object for further call chaining.
729   */
730  JctCompiler inheritSystemModulePath(boolean inheritSystemModulePath);
731
732  /**
733   * Get the output locale.
734   *
735   * <p>Unless otherwise changed or specified, implementations should default to
736   * {@link #DEFAULT_LOCALE}.
737   *
738   * @return the output locale to use.
739   */
740  Locale getLocale();
741
742  /**
743   * Set the output locale.
744   *
745   * <p>Unless otherwise changed or specified, implementations should default to
746   * {@link #DEFAULT_LOCALE}.
747   *
748   * @param locale the locale to use.
749   * @return this compiler for further call chaining.
750   */
751  JctCompiler locale(Locale locale);
752
753  /**
754   * Get the charset being used to write compiler logs with.
755   *
756   * <p>Unless otherwise changed or specified, implementations should default to
757   * {@link #DEFAULT_LOG_CHARSET}.
758   *
759   * @return the charset.
760   */
761  Charset getLogCharset();
762
763  /**
764   * Set the charset being used to write compiler logs with.
765   *
766   * <p>Unless otherwise changed or specified, implementations should default to
767   * {@link #DEFAULT_LOG_CHARSET}.
768   *
769   * @param logCharset the charset to use.
770   * @return this compiler for further call chaining.
771   */
772  JctCompiler logCharset(Charset logCharset);
773
774  /**
775   * Get the current file manager logging mode.
776   *
777   * <p>Unless otherwise changed or specified, implementations should default to
778   * {@link #DEFAULT_FILE_MANAGER_LOGGING_MODE}.
779   *
780   * @return the current file manager logging mode.
781   */
782  LoggingMode getFileManagerLoggingMode();
783
784  /**
785   * Set how to handle logging calls to underlying file managers.
786   *
787   * <p>Unless otherwise changed or specified, implementations should default to
788   * {@link #DEFAULT_FILE_MANAGER_LOGGING_MODE}.
789   *
790   * @param fileManagerLoggingMode the mode to use for file manager logging.
791   * @return this compiler for further call chaining.
792   */
793  JctCompiler fileManagerLoggingMode(LoggingMode fileManagerLoggingMode);
794
795  /**
796   * Get the current diagnostic logging mode.
797   *
798   * <p>Unless otherwise changed or specified, implementations should default to
799   * {@link #DEFAULT_DIAGNOSTIC_LOGGING_MODE}.
800   *
801   * @return the current diagnostic logging mode.
802   */
803  LoggingMode getDiagnosticLoggingMode();
804
805  /**
806   * Set how to handle diagnostic capture.
807   *
808   * <p>Unless otherwise changed or specified, implementations should default to
809   * {@link #DEFAULT_DIAGNOSTIC_LOGGING_MODE}.
810   *
811   * @param diagnosticLoggingMode the mode to use for diagnostic capture.
812   * @return this compiler for further call chaining.
813   */
814  JctCompiler diagnosticLoggingMode(LoggingMode diagnosticLoggingMode);
815
816  /**
817   * Get how to perform annotation processor discovery.
818   *
819   * <p>Unless otherwise changed or specified, implementations should default to
820   * {@link #DEFAULT_ANNOTATION_PROCESSOR_DISCOVERY}.
821   *
822   * <p>Specifying any annotation processors explicitly with
823   * {@link #addAnnotationProcessors(Iterable)} or
824   * {@link #addAnnotationProcessors(Processor, Processor...)} will bypass this setting, treating it
825   * as being disabled.
826   *
827   * @return the processor discovery mode to use.
828   */
829  AnnotationProcessorDiscovery getAnnotationProcessorDiscovery();
830
831  /**
832   * Set how to perform annotation processor discovery.
833   *
834   * <p>Unless otherwise changed or specified, implementations should default to
835   * {@link #DEFAULT_ANNOTATION_PROCESSOR_DISCOVERY}.
836   *
837   * <p>Specifying any annotation processors explicitly with
838   * {@link #addAnnotationProcessors(Iterable)} or
839   * {@link #addAnnotationProcessors(Processor, Processor...)} will bypass this setting, treating it
840   * as being disabled.
841   *
842   * @param annotationProcessorDiscovery the processor discovery mode to use.
843   * @return this compiler for further call chaining.
844   */
845  JctCompiler annotationProcessorDiscovery(AnnotationProcessorDiscovery annotationProcessorDiscovery);
846}