public final class BytecodeCompiler extends Object
jbcsrc compiler.| Modifier and Type | Method and Description |
|---|---|
static com.google.common.base.Optional<CompiledTemplates> |
compile(TemplateRegistry registry,
boolean developmentMode,
ErrorReporter reporter)
Compiles all the templates in the given registry.
|
static void |
compileToJar(TemplateRegistry registry,
ErrorReporter reporter,
com.google.common.io.ByteSink sink)
Compiles all the templates in the given registry to a jar file written to the given output
stream.
|
static void |
writeSrcJar(TemplateRegistry registry,
com.google.common.collect.ImmutableMap<String,SoyFileSupplier> files,
com.google.common.io.ByteSink sink)
Writes the source files out to a
-src.jar. |
public static com.google.common.base.Optional<CompiledTemplates> compile(TemplateRegistry registry, boolean developmentMode, ErrorReporter reporter)
registry - All the templates to compiledevelopmentMode - Whether or not we are in development mode. In development mode we
compile classes lazilyreporter - The error reporterabsent() if compilation fails, in which case errors will
have been reported to the error reporter.public static void compileToJar(TemplateRegistry registry, ErrorReporter reporter, com.google.common.io.ByteSink sink) throws IOException
If errors are encountered, the error reporter will be updated and we will return. The contents of any data written to the sink at that point are undefined.
registry - All the templates to compilereporter - The error reportersink - The output sink to write the JAR to.IOExceptionpublic static void writeSrcJar(TemplateRegistry registry, com.google.common.collect.ImmutableMap<String,SoyFileSupplier> files, com.google.common.io.ByteSink sink) throws IOException
-src.jar. This places the soy files at the same
classpath relative location as their generated classes. Ultimately this can be used by
debuggers for source level debugging.
It is a little weird that the relative locations of the generated classes are not identical to the input source files. This is due to the disconnect between java packages and soy namespaces. We should consider using the soy namespace directly as a java package in the future.
registry - All the templates in the current compilation unitfiles - The source files by file pathsink - The source to write the jar fileIOException