use of com.android.tools.idea.templates.recipe.Recipe in project android by JetBrains.
the class ServiceXmlParser method analyzeRecipe.
private void analyzeRecipe(boolean findOnlyReferences, @Nullable Collection<File> openFiles, @Nullable SetMultimap<String, String> dependencies, @Nullable Collection<String> classpathEntries, @Nullable Collection<String> plugins, @Nullable Collection<File> sourceFiles, @Nullable Collection<File> targetFiles) {
RenderingContext context = null;
try {
File moduleRoot = new File(myModule.getModuleFilePath()).getParentFile();
// @formatter:off
context = RenderingContext.Builder.newContext(myRootPath, myModule.getProject()).withParams(myContext.toValueMap()).withOutputRoot(moduleRoot).withModuleRoot(moduleRoot).withFindOnlyReferences(findOnlyReferences).withGradleSync(false).intoOpenFiles(openFiles).intoDependencies(dependencies).intoClasspathEntries(classpathEntries).intoPlugins(plugins).intoSourceFiles(sourceFiles).intoTargetFiles(targetFiles).build();
// @formatter:on
String xml = FreemarkerUtils.processFreemarkerTemplate(context, myRecipeFile, null);
Recipe recipe = Recipe.parse(new StringReader(xml));
RecipeExecutor recipeExecutor = context.getRecipeExecutor();
recipe.execute(recipeExecutor);
} catch (TemplateProcessingException e) {
// TODO(b/31039466): Extra logging to track down a rare issue.
LOG.warn("Template processing exception with context in the following state: " + context);
throw new RuntimeException(e);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
Aggregations