/** * Parses, validates and compiles the given source. Calls the given acceptor for each * resource which is generated from the source. * * @param resourceSet - the {@link ResourceSet} to use * @param acceptor gets called once for each file generated in {@link IGenerator} */ public void compile(final ResourceSet resourceSet, IAcceptor<Result> acceptor) { try { List<Resource> resourcesToCheck = newArrayList(resourceSet.getResources()); if (generatorConfigProvider instanceof GeneratorConfigProvider) { GeneratorConfigProvider configProvider = (GeneratorConfigProvider) generatorConfigProvider; GeneratorConfig config = generatorConfigProvider.get(null); config.setJavaSourceVersion(javaCompiler.getJavaVersion()); GeneratorConfig existent = configProvider.install(resourceSet, config); if (existent != null) { existent.setJavaSourceVersion(javaCompiler.getJavaVersion()); configProvider.install(resourceSet, existent); } } Result result = resultProvider.get(); result.setJavaCompiler(javaCompiler); result.setCheckMode(getCheckMode()); result.setResources(resourcesToCheck); result.setResourceSet(resourceSet); result.setOutputConfigurations(getOutputConfigurations()); result.doGenerate(); acceptor.accept(result); } catch (Exception e) { Exceptions.throwUncheckedException(e); } }
/** * Fix for NPE in EclipseGeneratorConfigProvider. * * @return GeneratorConfigProvider */ @Override public Class<? extends IGeneratorConfigProvider> bindIGeneratorConfigProvider() { return GeneratorConfigProvider.class; }