Class Compiler
java.lang.Object
com.google.testing.compile.Compiler
An object that can
compile(JavaFileObject...) Java source files.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe annotation processor path.The compilation class path.final Compilationcompile(Iterable<? extends JavaFileObject> files) Compiles Java source files.final Compilationcompile(JavaFileObject... files) Compiles Java source files.static Compilercompiler(JavaCompiler javaCompiler) Returns aCompilerthat uses a givenJavaCompilerinstance.static Compilerjavac()Returns thejavaccompiler.abstract com.google.common.collect.ImmutableList<String> options()The options passed to the compiler.abstract com.google.common.collect.ImmutableList<Processor> The annotation processors applied during compilation.final CompilerwithAnnotationProcessorPath(Iterable<File> annotationProcessorPath) Uses the given annotation processor path for the compilation instead of the system annotation processor path.final CompilerwithClasspath(Iterable<File> classPath) Uses the given classpath for the compilation instead of the system classpath.final CompilerwithClasspathFrom(ClassLoader classloader) Deprecated.final CompilerwithOptions(Iterable<? extends Object> options) Passes command-line options to the compiler.final CompilerwithOptions(Object... options) Passes command-line options to the compiler.final CompilerwithProcessors(Iterable<? extends Processor> processors) Uses annotation processors during compilation.final CompilerwithProcessors(Processor... processors) Uses annotation processors during compilation.
-
Constructor Details
-
Compiler
public Compiler()
-
-
Method Details
-
javac
Returns thejavaccompiler. -
compiler
Returns aCompilerthat uses a givenJavaCompilerinstance. -
processors
The annotation processors applied during compilation. -
options
The options passed to the compiler. -
classPath
-
annotationProcessorPath
-
withProcessors
Uses annotation processors during compilation. These replace any previously specified.Note that most annotation processors cannot be reused for more than one compilation.
- Returns:
- a new instance with the same options and the given processors
-
withProcessors
Uses annotation processors during compilation. These replace any previously specified.Note that most annotation processors cannot be reused for more than one compilation.
- Returns:
- a new instance with the same options and the given processors
-
withOptions
-
withOptions
-
withClasspathFrom
Deprecated.preferwithClasspath(Iterable). This method only supportsURLClassLoaderand the default system classloader, andFiles are usually a more natural way to expression compilation classpaths than class loaders.Uses the classpath from the passed on classloader (and its parents) for the compilation instead of the system classpath.- Throws:
IllegalArgumentException- if the given classloader had classpaths which we could not determine or use for compilation.
-
withClasspath
-
withAnnotationProcessorPath
-
compile
Compiles Java source files.- Returns:
- the results of the compilation
-
compile
Compiles Java source files.- Returns:
- the results of the compilation
-
withClasspath(Iterable).