in src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py [0:0]
def do_compile(self, invalidation_check, compile_contexts, classpath_product):
"""Executes compilations for the invalid targets contained in a single chunk."""
invalid_targets = [vt.target for vt in invalidation_check.invalid_vts]
valid_targets = [vt.target for vt in invalidation_check.all_vts if vt.valid]
if self.execution_strategy == self.HERMETIC:
self._set_directory_digests_for_valid_target_classpath_directories(valid_targets, compile_contexts)
for valid_target in valid_targets:
cc = self.select_runtime_context(compile_contexts[valid_target])
classpath_product.add_for_target(
valid_target,
[(conf, self._classpath_for_context(cc)) for conf in self._confs],
)
self.register_extra_products_from_contexts(valid_targets, compile_contexts)
if not invalid_targets:
return
# This ensures the workunit for the worker pool is set before attempting to compile.
with self.context.new_workunit('isolation-{}-pool-bootstrap'.format(self.name())) \
as workunit:
# This uses workunit.parent as the WorkerPool's parent so that child workunits
# of different pools will show up in order in the html output. This way the current running
# workunit is on the bottom of the page rather than possibly in the middle.
worker_pool = WorkerPool(workunit.parent,
self.context.run_tracker,
self._worker_count)
# Prepare the output directory for each invalid target, and confirm that analysis is valid.
for target in invalid_targets:
cc = self.select_runtime_context(compile_contexts[target])
safe_mkdir(cc.classes_dir.path)
# Now create compile jobs for each invalid target one by one, using the classpath
# generated by upstream JVM tasks and our own prepare_compile().
jobs = self._create_compile_jobs(compile_contexts,
invalid_targets,
invalidation_check.invalid_vts,
classpath_product)
exec_graph = ExecutionGraph(jobs, self.get_options().print_exception_stacktrace)
try:
exec_graph.execute(worker_pool, self.context.log)
except ExecutionFailure as e:
raise TaskError("Compilation failure: {}".format(e))