use of com.google.devtools.build.lib.analysis.actions.TemplateExpansionAction.Template in project bazel by bazelbuild.
the class DataBinding method createAnnotationFile.
/**
* Creates and returns the generated Java source that data binding's annotation processor
* reads to translate layout info xml (from {@link #getLayoutInfoFile} into the classes that
* end user code consumes.
*/
static Artifact createAnnotationFile(RuleContext ruleContext, boolean isLibrary) {
Template template = Template.forResource(DataBinding.class, "databinding_annotation_template.txt");
List<Substitution> subs = new ArrayList<>();
subs.add(Substitution.of("%module_package%", AndroidCommon.getJavaPackage(ruleContext)));
// TODO(gregce): clarify or remove the sdk root
subs.add(Substitution.of("%sdk_root%", "/not/used"));
subs.add(Substitution.of("%layout_info_dir%", getLayoutInfoFile(ruleContext).getExecPath().getParentDirectory().toString()));
// Unused.
subs.add(Substitution.of("%export_class_list_to%", "/tmp/exported_classes"));
subs.add(Substitution.of("%is_library%", Boolean.toString(isLibrary)));
// TODO(gregce): update this
subs.add(Substitution.of("%min_sdk%", "14"));
Artifact output = ruleContext.getPackageRelativeArtifact(String.format("databinding/%s/DataBindingInfo.java", ruleContext.getLabel().getName()), ruleContext.getConfiguration().getGenfilesDirectory());
ruleContext.registerAction(new TemplateExpansionAction(ruleContext.getActionOwner(), output, template, subs, false));
return output;
}
Aggregations