Skip to content

Commit

Permalink
Fix undigested m.jar under validated targets (pantsbuild#8479)
Browse files Browse the repository at this point in the history
### Problem

For hermetic rsc+zinc, m.jar in validated targets are not digested, causing downstream targets to error out with missing digest. E.g.
```
zinc[rsc-and-zinc](<target>) failed: ClasspathEntry ClasspathEntry(path='/Users/user/workspace/s2/.pants.d/compile/rsc/c1e3836b60e5/<target_id>/current/rsc/m.jar', directory_digest=None) didn't have a Digest, so won't be present for hermetic execution of zinc
                   Traceback:
                     File "/Users/user/workspace/pants/src/python/pants/backend/jvm/tasks/jvm_compile/execution_graph.py", line 281, in worker
                       work()
                   
                     File "/Users/user/workspace/pants/src/python/pants/backend/jvm/tasks/jvm_compile/execution_graph.py", line 42, in __call__
                       self.fn()
                   
                     File "/Users/user/workspace/pants/src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py", line 982, in _default_work_for_vts
                       counter)
                   
                     File "/Users/user/workspace/pants/src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py", line 593, in _compile_vts
                       self._get_plugin_map('scalac', ScalaPlatform.global_instance(), ctx.target),
```

### Solution

Make sure m.jar in validated targets are digested.
  • Loading branch information
wisechengyi authored Oct 17, 2019
1 parent c31c162 commit ca4aa40
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,20 @@ def confify(entries):
# Ensure that the jar/rsc jar is on the rsc_mixed_compile_classpath.
for target in targets:
merged_cc = compile_contexts[target]
rsc_cc = merged_cc.rsc_cc
zinc_cc = merged_cc.zinc_cc
rsc_cc = merged_cc.rsc_cc
# Make sure m.jar is digested if it exists when the target is validated.
if rsc_cc.rsc_jar_file.directory_digest is None and os.path.exists(rsc_cc.rsc_jar_file.path):
relpath = fast_relpath(rsc_cc.rsc_jar_file.path, get_buildroot())
classes_dir_snapshot, = self.context._scheduler.capture_snapshots([
PathGlobsAndRoot(
PathGlobs([relpath]),
get_buildroot(),
Digest.load(relpath),
),
])
rsc_cc.rsc_jar_file.hydrate_missing_directory_digest(classes_dir_snapshot.directory_digest)

if rsc_cc.workflow is not None:
cp_entries = rsc_cc.workflow.match({
self.JvmCompileWorkflowType.zinc_only: lambda: confify([self._classpath_for_context(zinc_cc)]),
Expand Down

0 comments on commit ca4aa40

Please sign in to comment.