def execute(self):
with self.context.new_workunit(name="dx-compile", labels=[WorkUnit.MULTITOOL]):
targets = self.context.targets(self.is_dextarget)
with self.invalidated(targets) as invalidation_check:
invalid_targets = []
for vt in invalidation_check.invalid_vts:
invalid_targets.extend(vt.targets)
for target in invalid_targets:
outdir = self.dx_out(target)
safe_mkdir(outdir)
classes_by_target = self.context.products.get_data("classes_by_target")
classes = []
def add_to_dex(tgt):
target_classes = classes_by_target.get(tgt)
if target_classes:
def add_classes(target_products):
for _, products in target_products.abs_paths():
for prod in products:
classes.append(prod)
add_classes(target_classes)
target.walk(add_to_dex)
if not classes:
raise TaskError("No classes were found for {0!r}.".format(target))
args = self._render_args(outdir, classes)
self._compile_dex(args, target.build_tools_version)
for target in targets:
self.context.products.get("dex").add(target, self.dx_out(target)).append(self.DEX_NAME)
def dx_jar_tool(self, build_tools_version):
Return the appropriate dx.jar.
:param string build_tools_version: The Android build-tools version number (e.g. "19.1.0").