Class JavaCompiler
- All Implemented Interfaces:
Generator, ResourceProvider
The JavaCompiler generator provides two types of resources.
-
The
JavaSourceFiles of the project as configured withaddSources(org.jdrupes.builder.api.FileTree<org.jdrupes.builder.java.JavaSourceFile>)in response to aResourceRequestwithResourceTypeJavaTypes.JavaSourceTreeType(or a more general type). -
The
ClassFiles that result from compiling the sources in response to aResourceRequestwithResourceTypeJavaTypes.ClassTreeType(or a more general type such asJavaTypes.ClasspathElementType).
No attempt has been made to define types for the options of
the java compiler. Rather, the options are passed as strings
as the ToolProvider API suggests. There are some noteworthy
exceptions for options that are directly related to resource
types (files, directory trees, paths) from the builder context.
If no "-g..." option is specified, the generator adds "-g" and
thus generates full debug information. If you want to restore the
default behavior of the java compiler, you have to specify
-g:[lines, source] explicitly.
-
Field Summary
Fields inherited from class AbstractProvider
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal JavaCompileraddSources(Path directory, String pattern) Adds the files from the given directory matching the given pattern.final JavaCompileraddSources(Stream<FileTree<JavaSourceFile>> sources) Adds the sources.final JavaCompileraddSources(FileTree<JavaSourceFile> sources) Adds the source tree.Returns the destination directory.destination(Path destination) Sets the destination directory.doProvide(ResourceRequest<T> requested) Invoked byAbstractProvider.provide(ResourceRequest)after checking if the invocation is allowed.sources()Return the source trees configured for the compiler.Methods inherited from class JavaTool
logDiagnostic, logDiagnostics, optionArgument, options, options, optionsMethods inherited from class AbstractGenerator
cleanup, name, name, newResource, project, toStringMethods inherited from class AbstractProvider
provideMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceProvider
provide
-
Constructor Details
-
JavaCompiler
Instantiates a new java compiler.- Parameters:
project- the project
-
-
Method Details
-
destination
Returns the destination directory. Defaults to "classes".- Returns:
- the destination
-
destination
Sets the destination directory. ThePathis resolved against the project's build directory (seeProject.buildDirectory()).- Parameters:
destination- the new destination- Returns:
- the java compiler
-
addSources
Adds the source tree.- Parameters:
sources- the sources- Returns:
- the java compiler
-
addSources
Adds the files from the given directory matching the given pattern. Short foraddSources(project().newFileTree(directory, pattern, JavaSourceFile.class)).- Parameters:
directory- the directorypattern- the pattern- Returns:
- the resources collector
-
addSources
Adds the sources.- Parameters:
sources- the sources- Returns:
- the java compiler
-
sources
Return the source trees configured for the compiler.- Returns:
- the resources
-
doProvide
Description copied from class:AbstractProviderInvoked byAbstractProvider.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
T- the generic type- Parameters:
requested- the requested- Returns:
- the stream
-