// Gather the Java source code to compile.
final String code = Joiner.on("\n").join(lines);
MockResourceOracle sourceOracle = new MockResourceOracle();
sourceOracle.addOrReplace(new MockJavaResource("test.EntryPoint") {
@Override
public CharSequence getContent() {
return code;
}
});
sourceOracle.add(JavaAstConstructor.getCompilerTypes());
sourceOracle.add(additionalResources);
PrecompileTaskOptions options = new PrecompileTaskOptionsImpl();
options.setOutput(JsOutputOption.PRETTY);
options.setRunAsyncEnabled(false);
CompilerContext context = new CompilerContext.Builder().options(options)
.minimalRebuildCache(new MinimalRebuildCache()).build();
ConfigProps config = new ConfigProps(Arrays.asList(recordFileNamesProp,
recordLineNumbersProp));
CompilationState state =
CompilationStateBuilder.buildFrom(logger, context,
sourceOracle.getResources(), null);
JProgram jProgram = AstConstructor.construct(logger, state, options, config);
jProgram.addEntryMethod(findMethod(jProgram, "onModuleLoad"));
if (inline) {
MethodInliner.exec(jProgram);