saker.java.compiler Documentation TaskDoc JavaDoc Packages
Describes various options as the input to Java compilation. The options can be used in saker.java.compile() CompilerOptions parameter to specify options which are added to the given compilation based on the compilation Identifier and Language qualifiers. The specified values in the CompilerOptions argument is merged into the compilation parameters of the task and the compilation will be executed based on the merged options.
Summary
Fields
AddExportsSpecifies the additional module export definitions when compiling for Java 9 or later.
AddReadsSpecifies the additional module read definitions when compiling for Java 9 or later.
AllowTargetReleaseMismatchSets if mismatching TargetVersion, SourceVersion and --release values are allowed to be used.
AnnotationProcessorOptionsSpecifies the global key-value options that should be passed to all annotation processors.
AnnotationProcessorsSpecifies the annotation processors that should be used during compilation.
BootClassPathInput boot class path for the compilation.
BuildIncrementalSpecifies if incremental Java compilation should be used or not.
ClassPathInput class path for the compilation.
DebugInfoSpecifies the debugging informations to be included in the generated class files.
GenerateNativeHeadersSpecifies whether or not native headers should be generated for the compiled source files.
IdentifierSpecifies the Identifier that serves as a qualifier for compiler option merging.
LanguageSpecifies the Language this options applies to.
ModuleMainClassSpecifies a Java class binary name that should be injected in the generated module-info.class file.
ModulePathInput module path for the compilation.
ModuleVersionSpecifies a version string that should be injected in the generated module-info.class file.
ParallelProcessingSpecifies if the compiler task may run the annotation processors in a parallel manner.
ParameterNamesSpecifies whether or not the parameter names of methods and constructors should be included in the generated class files.
ParametersSpecifies the command line parameters that should be passed to javac.
PatchEnablePreviewSets if the --enable-preview requirement on the generated class files should be patched.
ProcessorInputLocationsSpecifies a read-only input location for annotation processors.
SDKsSpecifies the SDKs (Software Development Kits) used by the compilation task.
SourceDirectoriesInput source directories for the compilation.
SourceVersionSpecifies the accepted source version.
SuppressWarningsSpecifies the warning types which should be suppressed by the compiler task.
TargetVersionSpecifies the target version of the class files.
Fields
Specifies the additional module export definitions when compiling for Java 9 or later. Specifying this option will add the appropriate --add-exports options to the Java compiler backend. The also option accepts string values in the format of module/package=other-module(,other-module)*. If the target module is omitted, ALL-UNNAMED is used.
Specifies the additional module read definitions when compiling for Java 9 or later. Specifying this option will add the appropriate --add-reads options to the Java compiler backend. The also option accepts string values in the format of module=other-module(,other-module)*.
Sets if mismatching TargetVersion, SourceVersion and --release values are allowed to be used. 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. WARNING: The specified TargetVersion shouldn't be greater than the --release version. Compilation may result in error if you target a more recent release than the specified --release. WARNING: Other general incompatibility errors may occurr if you intend to use bytecode instructions on older Java releases where they don't exist. By setting this to true, the compile task will directly set the specified TargetVersion, SourceVersion and --release parameter values as they are specified as inputs. No compatibility validation will be performed for these. This generally can be used to generate bytecode for older releases while sometimes using newer language features. This is a completely undocumented and unreliable feature of this build task and we don't recommend using it without thorough testing or in general.
Specifies the global key-value options that should be passed to all annotation processors. All the entries in this map will be added without modification to the options which are used for the processors.
Specifies the annotation processors that should be used during compilation. Annotation processors are plugins into the compilation. They can examine the compiled source code and generate various sources, classes, and resources based on that. Annotation processors can be constructed by other tasks in the build system. See saker.java.processor() or the use-case documentation for your processor of interest. Global options can be specified for the processors using AnnotationProcessorOptions. Input locations can be specified using ProcessorInputLocations.
Input boot class path for the compilation. The class files in the specified class path will used as the boot class path during Java compilation. The value may be paths to JARs or class directories, wildcards to specify multiple one easily, outputs of previous compilations, paths based on SDKs, or class paths from other tasks. Class paths of compilation outputs will be transitive added. Any Class-Path or similar attributes in JAR file manifests are ignored.
Specifies if incremental Java compilation should be used or not. The default value is true. Setting this to false will cause the task to use legacy compilation, and will call the javac backend with the least modification to the input parameters as possible. Using it will result in the compile Parameters being passed directly to the backend, and annotation processors will be called by the javac backed instead of the task implementation. This option should only be used when there are issues with the incremental Java compilation implementation. If you ever need to turn this feature off, make sure to file an issue about your use-case as this is considered to be a bug in the incremental compiler. Issues at: https://github.com/sakerbuild/saker.java.compiler/issues
Input class path for the compilation. The class files in the specified class path will be added to the available classes during Java compilation. The value may be paths to JARs or class directories, wildcards to specify multiple one easily, outputs of previous compilations, paths based on SDKs, or class paths from other tasks. Class paths of compilation outputs will be transitive added. Any Class-Path or similar attributes in JAR file manifests are ignored.
Specifies the debugging informations to be included in the generated class files. The default is all. May specify empty collection to signal no information to be included. Corresponds to the -parameters command line option for javac.
Specifies whether or not native headers should be generated for the compiled source files. When set to true, the task will create C language bindings for any native declarations in the files. The created header files can be included by C/C++ and other language compilers if appropriate. Use the HeaderDirectory field of the task output to get a path to the generated headers.
Specifies the Identifier that serves as a qualifier for compiler option merging. The default value is null. The compiler options will only be merged to the target compilation task options if the task Identifier parameter contains all of the parts declared in this Identifier. An identifier constists of dash separated parts of character sequences of a-z, A-Z, 0-9, _, ., (), [], @. If no Identifier is specified, the option merging is not constrained by the Identifier, and the options will be merged without checking it.
Specifies the Language this options applies to. The default value is null. The Language serves as a qualifier for merging options into the compilation task. If the target language doesn't match the language declaration in this options, the options won't be merged into the compilation task. If the Language is null, then option merging is not constrained by the Language, and the options will be merged without checking it.
Specifies a Java class binary name that should be injected in the generated module-info.class file. When the compilation targets Java 9 or later, and uses modules (module-info.java), specifying this option will cause the compiler task to inject the main class attribute in the generated module-info.class class file. The task will not verify if the specified class exists or not.
Input module path for the compilation. The specified JARs and class directories will be used as the module path durin Java compilation. The value may be paths to JARs or class directories, wildcards to specify multiple one easily, outputs of previous compilations, paths based on SDKs, or module paths from other tasks. Module paths of compilation outputs will be transitive added. This option only has relevance if the compilation is done for JDK9 or later.
Specifies a version string that should be injected in the generated module-info.class file. When the compilation targets Java 9 or later, and uses modules (module-info.java), specifying this option will cause the compiler task to inject the version attribute in the generated module-info.class class file. The task will not check if the specified version is syntactically correct.
Specifies if the compiler task may run the annotation processors in a parallel manner. The default value is true. Running annotation processors in parallel may result in performance increase, as they can generate their classes and resources without waiting on each other. In general, parallel processing shouldn't distrupt the operation of annotation processors, however, if developers notice any unexpected processor outputs, they may check if turning parallel processing off helps. When parallel processing is on, the result of the Processor.process() function is ignored by the compiler.
Specifies whether or not the parameter names of methods and constructors should be included in the generated class files. If so, the parameter names will be available through the Reflection APIs. The default is true. Corresponds to the -parameters command line option for javac.
Specifies the command line parameters that should be passed to javac. The specified parameters will be passed to the Java compiler backend with minimal modifications by the compiler task. The -processorpath and -processor parameters are ignored. Use the annotation processor options for the compiler task. The -source and -target parameters are ignored. Use SourceVersion and TargetVersion parameters for the compiler task. The -sourcepath parameter is ignored. Use SourceDirectories parameter to specify source inputs. The -cp, -classpath, --class-path parameters are merged with the ClassPath parameter. Developers should use the ClassPath parameter instead of these options. The -p and --module-path are merged with the ModulePath option. Developers should use ModulePath instead. The -bootclasspath and --boot-class-path parameters are merged with BootClassPath. Developers should use BootClassPath instead. The -A parameters are stripped and merged with the AnnotationProcessorOptions option.
Sets if the --enable-preview requirement on the generated class files should be patched. If this flag is set to true, then the compile task will modify the minor version of the class files from 0xFFFF to 0x0000. As a result of this, they can be run using javac without specifying the --enable-preview flag for it. Note that this feature may break on future versions of Java.
Specifies a read-only input location for annotation processors. The value is a string-path map which contains the names of locations and the directory paths from where processors can read resources from. The processors can use the Filer API to read resources, by passing StandardLocation.locationFor(name) as the location argument.
Specifies the SDKs (Software Development Kits) used by the compilation task. SDKs represent development kits that are available in the build environment and to the task. For Java compilation, they can be used to resolve class and module paths against, or to specify a different JDK to use for compilation. SDKs are referenced by simple string names in a case-insensitive way. The "Java" SDK is used by the compilation task to determine which JDK to use. If a different JDK is specified than the one the build is running on, then the task will spawn a new Java process that it delegates the compilation to. (i.e. forks a compiler process) The saker.java.sdk() task can be used to find JDKs with a specific version during build.
Input source directories for the compilation. It is used to specify which files should be compiled. It can accept a single path to the source directory containing .java files.
Specifies the accepted source version. The compiled Java sources should comply to the specified source version number. The value can be a positive integer representing the Java major release number, or in the format of RELEASE_<num>.
Specifies the warning types which should be suppressed by the compiler task.
Specifies the target version of the class files. The generated class files will be used to target the Java VM with the specified version. The value can be a positive integer representing the Java major release number, or in the format of RELEASE_<num>.