CompilerContext oldCompilerContext = new CompilerContext();
oldCompilerContext.getOptions().setStrict(true);
CompilationState oldState =
CompilationStateBuilder.buildFrom(logger, oldCompilerContext, resources);
oldState.addGeneratedCompilationUnits(logger, generatedUnits);
MockLibrary oldLibrary = new MockLibrary("OldLib");
Collection<CompilationUnit> oldCompilationUnits =
Lists.newArrayList(oldState.getCompilationUnits());
CompilationUnitInvalidator.retainValidUnits(logger, oldCompilationUnits,
oldState.getValidClasses(), new CompilationErrorsIndexImpl());
for (CompilationUnit compilationUnit : oldCompilationUnits) {
oldLibrary.addCompilationUnit(compilationUnit);
}
// Create and return a LibraryTypeOracle that doesn't have any compilation units loaded but
// which can lazy load all of them out of a previously compiled library.
LibraryGroup libraryGroup = LibraryGroup.fromLibraries(Lists.newArrayList(oldLibrary), false);