Class TestCompiler
java.lang.Object
org.springframework.aot.test.generator.compile.TestCompiler
Utility that can be used to dynamically compile and test Java source code.
- Since:
- 6.0
- Author:
- Phillip Webb
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionvoidCompile content from this instance.voidcompile(SourceFile sourceFile, Consumer<Compiled> compiled) Compile content from this instance along with the additional provided source file.voidcompile(SourceFiles sourceFiles, Consumer<Compiled> compiled) Compile content from this instance along with the additional provided source files.voidcompile(SourceFiles sourceFiles, ResourceFiles resourceFiles, Consumer<Compiled> compiled) Compile content from this instance along with the additional provided source and resource files.voidcompile(WritableContent content, Consumer<Compiled> compiled) Compile content from this instance along with the additional provided content.static TestCompilerforCompiler(JavaCompiler javaCompiler) Return a newTestCompilerbacked by the givenJavaCompiler.static TestCompilerReturn a newTestCompilerbacked by the system java compiler.withResources(ResourceFile... resourceFiles) Return a newTestCompilerinstance with addition resource files.withResources(ResourceFiles resourceFiles) Return a newTestCompilerinstance with addition resource files.withSources(SourceFile... sourceFiles) Return a newTestCompilerinstance with addition source files.withSources(SourceFiles sourceFiles) Return a newTestCompilerinstance with addition source files.
- 
Method Details- 
forSystemReturn a newTestCompilerbacked by the system java compiler.- Returns:
- a new TestCompilerinstance
 
- 
forCompilerReturn a newTestCompilerbacked by the givenJavaCompiler.- Parameters:
- javaCompiler- the java compiler to use
- Returns:
- a new TestCompilerinstance
 
- 
withSourcesReturn a newTestCompilerinstance with addition source files.- Parameters:
- sourceFiles- the additional source files
- Returns:
- a new TestCompilerinstance
 
- 
withSourcesReturn a newTestCompilerinstance with addition source files.- Parameters:
- sourceFiles- the additional source files
- Returns:
- a new TestCompilerinstance
 
- 
withResourcesReturn a newTestCompilerinstance with addition resource files.- Parameters:
- resourceFiles- the additional resource files
- Returns:
- a new TestCompilerinstance
 
- 
withResourcesReturn a newTestCompilerinstance with addition resource files.- Parameters:
- resourceFiles- the additional resource files
- Returns:
- a new TestCompilerinstance
 
- 
compileCompile content from this instance along with the additional provided content.- Parameters:
- content- the additional content to compile
- compiled- a consumed used to further assert the compiled code
- Throws:
- CompilationException- if source cannot be compiled
 
- 
compileCompile content from this instance along with the additional provided source file.- Parameters:
- sourceFile- the additional source file to compile
- compiled- a consumed used to further assert the compiled code
- Throws:
- CompilationException- if source cannot be compiled
 
- 
compileCompile content from this instance along with the additional provided source files.- Parameters:
- sourceFiles- the additional source files to compile
- compiled- a consumed used to further assert the compiled code
- Throws:
- CompilationException- if source cannot be compiled
 
- 
compilepublic void compile(SourceFiles sourceFiles, ResourceFiles resourceFiles, Consumer<Compiled> compiled) Compile content from this instance along with the additional provided source and resource files.- Parameters:
- sourceFiles- the additional source files to compile
- resourceFiles- the additional resource files to include
- compiled- a consumed used to further assert the compiled code
- Throws:
- CompilationException- if source cannot be compiled
 
- 
compileCompile content from this instance.- Parameters:
- compiled- a consumed used to further assert the compiled code
- Throws:
- CompilationException- if source cannot be compiled
 
 
-