pub struct JavaBuild { /* private fields */ }
Expand description
A builder for a javac
command that can be invoked.
If you need to customize the javac
command beyond what is provided here,
you can use the JavaBuild::command()
method to get a Command
that can be further customized with additional arguments.
Documentation on javac
options are based on
https://dev.java/learn/jvm/tools/core/javac/.
Implementations§
Source§impl JavaBuild
impl JavaBuild
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new JavaBuild
instance with default values,
which can be further customized using the builder methods.
Sourcepub fn compile(&self) -> Result<ExitStatus>
pub fn compile(&self) -> Result<ExitStatus>
Executes the javac
command based on this JavaBuild
instance.
Sourcepub fn command(&self) -> Result<Command>
pub fn command(&self) -> Result<Command>
Returns a Command
based on this JavaBuild
instance
that can be inspected or customized before being executed.
Sourcepub fn java_home<P: Into<PathBuf>>(&mut self, java_home: P) -> &mut Self
pub fn java_home<P: Into<PathBuf>>(&mut self, java_home: P) -> &mut Self
Override the default JAVA_HOME
path.
If not set, the default path is found using the JAVA_HOME
env var.
Sourcepub fn debug_info(&mut self, debug_info: DebugInfo) -> &mut Self
pub fn debug_info(&mut self, debug_info: DebugInfo) -> &mut Self
Set which debug info should be included in the generated class files
Sourcepub fn deprecation(&mut self, deprecation: bool) -> &mut Self
pub fn deprecation(&mut self, deprecation: bool) -> &mut Self
Configure the output about deprecation
usage.
- If
true
, javac will output full descriptions of all places where deprecated members/classes are used or overridden. - If
false
, javac will output only a summary on a per-source file basis.
Sourcepub fn enable_preview_features(
&mut self,
enable_preview_features: bool,
) -> &mut Self
pub fn enable_preview_features( &mut self, enable_preview_features: bool, ) -> &mut Self
Enable or disable preview language features.
Sourcepub fn class_path<P: AsRef<OsStr>>(&mut self, class_path: P) -> &mut Self
pub fn class_path<P: AsRef<OsStr>>(&mut self, class_path: P) -> &mut Self
Specify where to find user class files and annotation processors.
If no class paths are provided, the current directory will be used.
Sourcepub fn source_path<P: AsRef<OsStr>>(&mut self, source_path: P) -> &mut Self
pub fn source_path<P: AsRef<OsStr>>(&mut self, source_path: P) -> &mut Self
Specify where to find input source files.
If not specified, class_paths
will be searched for source files.
Sourcepub fn boot_class_path<P: AsRef<OsStr>>(
&mut self,
boot_class_path: P,
) -> &mut Self
pub fn boot_class_path<P: AsRef<OsStr>>( &mut self, boot_class_path: P, ) -> &mut Self
Specify where to find bootstrap class files.
If set, this will override the default search locations.
Sourcepub fn extension_dir<P: AsRef<OsStr>>(&mut self, extension_dir: P) -> &mut Self
pub fn extension_dir<P: AsRef<OsStr>>(&mut self, extension_dir: P) -> &mut Self
Specify where to find installed extensions.
If set, this will override the default search locations.
Sourcepub fn endorsed_dir<P: AsRef<OsStr>>(&mut self, endorsed_dir: P) -> &mut Self
pub fn endorsed_dir<P: AsRef<OsStr>>(&mut self, endorsed_dir: P) -> &mut Self
Specify where to find endorsed standards.
If set, this will override the default endorsed standards path.
Sourcepub fn annotation_processor<S: AsRef<OsStr>>(
&mut self,
annotation_processor: S,
) -> &mut Self
pub fn annotation_processor<S: AsRef<OsStr>>( &mut self, annotation_processor: S, ) -> &mut Self
Add an annotation processor to be run during compilation.
Setting this will bypass the default discovery process.
Sourcepub fn annotation_processor_path<P: AsRef<OsStr>>(
&mut self,
annotation_processor_path: P,
) -> &mut Self
pub fn annotation_processor_path<P: AsRef<OsStr>>( &mut self, annotation_processor_path: P, ) -> &mut Self
Add a path to search for annotation processors.
If not provided, the class paths will be searched by default.
Sourcepub fn method_paramater_metadata(
&mut self,
method_paramater_metadata: bool,
) -> &mut Self
pub fn method_paramater_metadata( &mut self, method_paramater_metadata: bool, ) -> &mut Self
Enable generation of metadata on method parameters such that the reflection API can be used to retrieve parameter info.
Sourcepub fn classes_out_dir<P: AsRef<OsStr>>(
&mut self,
classes_out_dir: P,
) -> &mut Self
pub fn classes_out_dir<P: AsRef<OsStr>>( &mut self, classes_out_dir: P, ) -> &mut Self
Specify where to place generated class files.
If not provided, class files will be placed in the same directory as the source files.
Sourcepub fn sources_out_dir<P: AsRef<OsStr>>(
&mut self,
sources_out_dir: P,
) -> &mut Self
pub fn sources_out_dir<P: AsRef<OsStr>>( &mut self, sources_out_dir: P, ) -> &mut Self
Specify where to place generated source files.
Sourcepub fn headers_out_dir<P: AsRef<OsStr>>(
&mut self,
headers_out_dir: P,
) -> &mut Self
pub fn headers_out_dir<P: AsRef<OsStr>>( &mut self, headers_out_dir: P, ) -> &mut Self
Specify where to place generated native header files.
Sourcepub fn annotation_parameter<K, V>(&mut self, key: K, value: V) -> &mut Self
pub fn annotation_parameter<K, V>(&mut self, key: K, value: V) -> &mut Self
Add a key-value pair to be passed as an option to an annotation processor.
Sourcepub fn warnings_as_errors(&mut self, warnings_as_errors: bool) -> &mut Self
pub fn warnings_as_errors(&mut self, warnings_as_errors: bool) -> &mut Self
If set to true
, warnings are treated as compilation errors.
Sourcepub fn file<P: AsRef<OsStr>>(&mut self, file: P) -> &mut Self
pub fn file<P: AsRef<OsStr>>(&mut self, file: P) -> &mut Self
Adds a Java source file to be compiled by javac.
Sourcepub fn files<P>(&mut self, files: P) -> &mut Self
pub fn files<P>(&mut self, files: P) -> &mut Self
Adds multiple Java source files to be compiled by javac.
This is the same as calling JavaBuild::file()
multiple times.