public interface SpoonCompiler extends FactoryAccessor
The Spoon model (see Factory
is built from input sources given as
files. Use build()
to create the Spoon model.
Once the model is built and stored in the factory, it
can be processed by using a ProcessingManager
.
Create an instance of the default implementation of the Spoon compiler by
using Launcher.createCompiler()
. For example:
SpoonCompiler compiler = Spoon.createCompiler(); Factory factory = Spoon.createFactory(); List<SpoonFile> files = SpoonResourceHelper.files("myFile.java"); compiler.build(factory, files);
Launcher.createCompiler()
Modifier and Type | Method and Description |
---|---|
void |
addInputSource(File source)
Adds a file/directory to be built.
|
void |
addInputSource(SpoonResource source)
Adds a file/directory (as a CtResource) to be built.
|
void |
addInputSources(List<SpoonResource> resources) |
void |
addTemplateSource(File source)
Adds a file/directory to be used to build templates.
|
void |
addTemplateSource(SpoonResource source)
Adds a file/directory (as a CtResource) to be used to build templates.
|
void |
addTemplateSources(List<SpoonResource> resources) |
boolean |
build()
Builds the program's model with this compiler's factory and stores the
result into this factory.
|
boolean |
compile()
Generates the bytecode associated to the classes stored in this
compiler's factory.
|
boolean |
compileInputSources()
Generates the bytecode by compiling the input sources.
|
void |
forceBuild(SpoonResource source)
When
setBuildOnlyOutdatedFiles(boolean) is true, adds a resource
to the forced-to-be-built list. |
void |
generateProcessedSourceFiles(OutputType outputType)
Generates the source code associated to the classes stored in this
compiler's factory.
|
File |
getDestinationDirectory()
Gets the output directory of this compiler.
|
String |
getEncoding()
Gets the encoding used by this compiler.
|
Set<File> |
getInputSources()
Gets all the files/directories given as input sources to this builder
(see
addInputSource(File) ). |
File |
getOutputDirectory()
Gets the output directory of this compiler.
|
String[] |
getSourceClasspath()
Gets the classpath that is used to build/compile the input sources.
|
String[] |
getTemplateClasspath()
Gets the classpath that is used to build the template sources.
|
Set<File> |
getTemplateSources()
Gets all the files/directories given as template sources to this builder
(see
addTemplateSource(File) ). |
void |
process(List<String> processorTypes)
Processes the Java model with the given processors.
|
void |
setBuildOnlyOutdatedFiles(boolean buildOnlyOutdatedFiles)
Sets this compiler to optimize the model building process by ignoring
files that has not be modified since the latest source code generation.
|
void |
setDestinationDirectory(File destinationDirectory)
Sets the destination directory for the class files.
|
void |
setEncoding(String encoding)
Sets the encoding to use when different from the system encoding.
|
void |
setOutputDirectory(File outputDirectory)
Sets the output directory for the source files.
|
void |
setSourceClasspath(String... classpath)
Sets the classpath that is used to build/compile the input sources.
|
void |
setTemplateClasspath(String... classpath)
Sets the classpath that is used to build the template sources.
|
getFactory, setFactory
void addInputSource(File source) throws IOException
source
- file or directory to addIOException
void setDestinationDirectory(File destinationDirectory) throws IOException
destinationDirectory
- destination directoryIOException
File getDestinationDirectory()
void setOutputDirectory(File outputDirectory) throws IOException
outputDirectory
- output directoryIOException
File getOutputDirectory()
void addInputSource(SpoonResource source)
source
- file or directory to addSet<File> getInputSources()
addInputSource(File)
).void addTemplateSource(File source) throws IOException
source
- file or directory to addIOException
void addTemplateSource(SpoonResource source)
source
- file or directory to addSet<File> getTemplateSources()
addTemplateSource(File)
).void addInputSources(List<SpoonResource> resources)
void addTemplateSources(List<SpoonResource> resources)
boolean build() throws Exception
Exception
- when a building problem occursgetSourceClasspath()
,
getTemplateClasspath()
void generateProcessedSourceFiles(OutputType outputType) throws Exception
getOutputDirectory()
.outputType
- the output methodException
boolean compile()
getDestinationDirectory()
.getSourceClasspath()
boolean compileInputSources() throws Exception
getDestinationDirectory()
.Exception
getSourceClasspath()
String[] getSourceClasspath()
compileInputSources()
,
build()
,
compile()
void setSourceClasspath(String... classpath)
String[] getTemplateClasspath()
setSourceClasspath(java.lang.String...)
for the meaning of the returned string.void setTemplateClasspath(String... classpath)
void setBuildOnlyOutdatedFiles(boolean buildOnlyOutdatedFiles)
void forceBuild(SpoonResource source)
setBuildOnlyOutdatedFiles(boolean)
is true, adds a resource
to the forced-to-be-built list. All the files added here will be build
even if no changes are detected on the file system. This list has no
impacts if @link #setBuildOnlyOutdatedFiles(boolean)} is false.void setEncoding(String encoding)
String getEncoding()
Copyright © 2007–2014 Inria. All rights reserved.