saker.java.compiler Documentation TaskDoc JavaDoc Packages
public interface JavaCompilationTaskBuilder
Builder class for configuring and constructing a Java compiler worker task.

Clients shouldn't implement this interface.

Create a new instance using newBuilder().

Methods
public TaskFactory<extends JavaCompilerWorkerTaskOutput>
Builds the task factory for the compilation.
public JavaCompilationWorkerTaskIdentifier
Builds the task identifier that should be used to start the configured task.
public static JavaCompilationTaskBuilder
Creates a new builder instance.
public void
setAddExports(Collection<extends JavaAddExports> addExports)
Sets the add-exports configuration to pass to javac.
public void
setAddReads(Collection<extends JavaAddReads> addReads)
Sets the add-reads configuration to pass to javac.
public void
Sets if mismatching values are allowed for the target, source and --release values.
public void
setAnnotationProcessorOptions(Map<String, String> annotationProcessorOptions)
Sets the global key-value string options that should be passed to the annotation processors.
public void
Sets the annotation processors that should be used during the compilation.
public void
Sets the compilation identifier of the worker task to be automatically determined based on the configuration.
public void
Sets the compilation boot classpath.
public void
setBuildIncremental(Boolean buildIncremental)
Sets whether or not to compile the sources using the incremental compiler implementation.
public void
Sets the input compilation classpath.
public void
Sets the compilation identifier for the worker task.
public void
Sets the debug informations that should be included in the generated class files.
public void
setGenerateNativeHeaders(Boolean generateNativeHeaders)
Sets whether or not native headers should be generated for the compiled classes.
public void
setModuleMainClass(String moduleMainClass)
Sets the module main class name to inject into the generated module-info.class file.
public void
Sets the module path for the compilation.
public void
setModuleVersion(String moduleVersion)
Sets the module version string to inject into the generated module-info.class file.
public void
setParallelProcessing(Boolean parallelProcessing)
Sets whether or not the annotation processors should be run in a parallel way.
public void
setParameterNames(Boolean parameterNames)
Sets if the parameter names should be included in the generated class files.
public void
Sets the parameters that are directly passed to the javac backed during compilation.
public void
setPatchEnablePreview(boolean enabled)
Sets if the --enable-preview requirement in the generated class files should be patched.
public void
setProcessorInputLocations(Map<String, SakerPath> processorInputLocations)
Sets the read-only input locations that the annotation processors can read.
public void
Sets the SDKs that should be used during the compilation.
public void
setSourceDirectories(Collection<extends JavaSourceDirectory> sourceDirectories)
Sets the source directory for the compilation.
public void
Sets the source version of the source files.
public void
Sets the global warning types that should be suppressed by the compiler task.
public void
Sets the target version of the generated class files.
Builds the task factory for the compilation.

The task works specified by the configuration in this builder. The task should be started with the buildTaskIdentifier() as the task identifier.

The builder can be reused after this call.

The worker compiler task factory.
IllegalStateExceptionIf the builder is in an illegal state.
Builds the task identifier that should be used to start the configured task.

The builder can be reused after this call.

The task identifier.
Creates a new builder instance.
The builder.
public abstract void setAddExports(Collection<extends JavaAddExports> addExports)
Sets the add-exports configuration to pass to javac.
addExportsThe add-exports configurations.
public abstract void setAddReads(Collection<extends JavaAddReads> addReads)
Sets the add-reads configuration to pass to javac.
addReadsThe add-reads configurations.
saker.java.compiler 0.8.8
public abstract void setAllowTargetReleaseMismatch(boolean enabled)
Sets if mismatching values are allowed for the target, source and --release values.

WARNING: Using this flag may cause your class files to be binary incompatible with the platform you intend to run it on. This flag uses undocumented javac API to trick it into generating bytecode for different versions than it's used to. Using this may cause crashes in your application in unexpected ways.

If this is set to true, the compiler task will set the source, target, and --release values in a way that may allow generating bytecode for different Java versions than the one dicatated by the source version.

enabledtrue to enable mismatched values.
saker.java.compiler 0.8.6
public abstract void setAnnotationProcessorOptions(Map<String, String> annotationProcessorOptions)
Sets the global key-value string options that should be passed to the annotation processors.
annotationProcessorOptionsThe options.
public abstract void setAnnotationProcessors(Collection<extends JavaAnnotationProcessor> annotationProcessors)
Sets the annotation processors that should be used during the compilation.
annotationProcessorsThe processors.
public abstract void setAutomaticCompilationIdentifier(TaskDirectoryContext taskdircontext)
Sets the compilation identifier of the worker task to be automatically determined based on the configuration.

The task directory context is used to infer working directory related information for the compilation identifier.

taskdircontextThe task directory context or null if none.
public abstract void setBootClassPath(JavaClassPath bootClassPath)
Sets the compilation boot classpath.
bootClassPathThe boot classpath.
public abstract void setBuildIncremental(Boolean buildIncremental)
Sets whether or not to compile the sources using the incremental compiler implementation.

Setting this to false will cause the compiler task to fall back to the legacy compiler implementation that always compiles every input source file.

This can be used if you experience errors in the incremental compiler, or need to take advantage of legacy features. The non-incremental compilation may not be supported in some cases.

The default is true.

buildIncrementalfalse to not build incrementally.
public abstract void setClassPath(JavaClassPath classPath)
Sets the input compilation classpath.
classPathThe classpath.
public abstract void setCompilationIdentifier(CompilationIdentifier compilationIdentifier) throws NullPointerException
Sets the compilation identifier for the worker task.
compilationIdentifierThe compilation identifier.
NullPointerExceptionIf the argument is null.
public abstract void setDebugInfo(Collection<String> debugInfo)
Sets the debug informations that should be included in the generated class files.

Corresponds to the -g javac option.

The default is to include all debugging information.

debugInfoThe collection of debug information types to include, or null to use the default. The elements should be any of the contants defined in JavaDebugInfoType.
public abstract void setGenerateNativeHeaders(Boolean generateNativeHeaders)
Sets whether or not native headers should be generated for the compiled classes.

The default is false.

generateNativeHeaderstrue to generate native headers.
public abstract void setModuleMainClass(String moduleMainClass)
Sets the module main class name to inject into the generated module-info.class file.

The compiler task will insert the specified class name as the main class into the generated module-info class file. If there's no compiled module, nothing will be done.

The compiler task doesn't verify if a class with the specified name exists.

moduleMainClassThe main class name.
public abstract void setModulePath(JavaModulePath modulePath)
Sets the module path for the compilation.

If the compilation targets Java 8 or earlier, the module path will be ignored.

modulePathThe module path.
public abstract void setModuleVersion(String moduleVersion)
Sets the module version string to inject into the generated module-info.class file.

The compiler task will insert the specified version string as the main version into the generated module-info class file. If there's no compiled module, nothing will be done.

moduleVersionThe module version string.
public abstract void setParallelProcessing(Boolean parallelProcessing)
Sets whether or not the annotation processors should be run in a parallel way.

The incremental compiler runs the annotation processing in a parallel way to improve performance. If you experience issues with it, or need the resulf of Processor.process(Set<extends TypeElement>, RoundEnvironment) taken into account, set this to false.

The default is true.

parallelProcessingfalse to disable parallel annotation processing
public abstract void setParameterNames(Boolean parameterNames)
Sets if the parameter names should be included in the generated class files.

Corresponds to the -parameters javac option.

The default is true.

parameterNamestrue to include parameter names.
public abstract void setParameters(List<String> parameters)
Sets the parameters that are directly passed to the javac backed during compilation.

Some of the parameters may be specially handled by the compiler task. If available, it is recommended to configure the options using the appropriate builder method.

parametersThe parameters.
public abstract void setPatchEnablePreview(boolean enabled)
Sets if the --enable-preview requirement in the generated class files should be patched.

Setting this flag to true causes the compiler task to patch the minor version of the generated class files if the --enable-preview parameter is also used for compilation.

It will allow you to run the classes without specifying --enable-preview for the java command.

Note that this feature may break on future Java versions. This flag essentially modifies the minor version of the class files from 0xFFFF to 0x0000.

See also JEP 12: Preview Language and VM Features

enabledtrue to enable --enable-preview patching.
saker.java.compiler 0.8.6
public abstract void setProcessorInputLocations(Map<String, SakerPath> processorInputLocations) throws NullPointerException, InvalidPathFormatException
Sets the read-only input locations that the annotation processors can read.

The processors can access the files in the specified locations by using StandardLocation.locationFor(String) when opening a resource for reading.

processorInputLocationsThe input locations.
NullPointerExceptionIf any of the key or value are null.
InvalidPathFormatExceptionIf a specified path is not absolute.
public abstract void setSDKs(Map<String, SDKDescription> sdks)
Sets the SDKs that should be used during the compilation.

The SDKs are used to determine the JVM that compiles the sources, to resolve class and module paths.

If an SDK is not specified with the name Java, the default is included.

sdksThe SDKs to use.
public abstract void setSourceDirectories(Collection<extends JavaSourceDirectory> sourceDirectories)
Sets the source directory for the compilation.

The sources that are the input of the compilation are determined based on the argument.

sourceDirectoriesThe source directories.
public abstract void setSourceVersion(Integer version)
Sets the source version of the source files.
versionThe source version major number or null to use the default.
public abstract void setSuppressWarnings(Collection<String> suppressWarnings)
Sets the global warning types that should be suppressed by the compiler task.

The elements should be any of the constants in JavaCompilerWarningType.

suppressWarningsThe warning types to suppress.
public abstract void setTargetVersion(Integer version)
Sets the target version of the generated class files.
versionThe target version major number or null to use the default.