Skip to content

Commit

Permalink
Invalidate dependency targets for jvmdoc if --combined. (#7455)
Browse files Browse the repository at this point in the history
### Problem

The doc.scaladoc task (and likely also the doc.javadoc task), when used with --combined is skipping dependencies in the graph during the 'invalidation' stage, because it is not passing invalidate_dependents in the docable predicate that is part of the base class JvmDocGen.

See issue: #7434

### Solution

In the relevant spot in `JvmDocGen` class, this change passes the `invalidate_dependents` parameter to `self.invalidate()` with attribute `self.combined` for the value which is `True` for combined doc builds and `False` otherwise. 

### Result

This causes the invalidation logic to behave as expected, specifically, invalidating the dependencies within the entire graph for a combined doc build. I tested this locally to ensure the correct behavior, and ran all relevant unit tests.
  • Loading branch information
thoward authored and Stu Hood committed Apr 5, 2019
1 parent b170379 commit 454ce5e
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/python/pants/backend/jvm/tasks/jvmdoc_gen.py
Expand Up @@ -111,18 +111,25 @@ def docable(target):
if not targets:
return

with self.invalidated(targets) as invalidation_check:
def find_jvmdoc_targets():
with self.invalidated(targets, invalidate_dependents=self.combined) as invalidation_check:
def find_invalid_targets():
invalid_targets = set()
for vt in invalidation_check.invalid_vts:
invalid_targets.update(vt.targets)
return invalid_targets

jvmdoc_targets = list(find_jvmdoc_targets())
if self.combined:
self._generate_combined(jvmdoc_targets, create_jvmdoc_command)
else:
self._generate_individual(jvmdoc_targets, create_jvmdoc_command)
invalid_targets = list(find_invalid_targets())
if invalid_targets:
if self.combined:
self._generate_combined(targets, create_jvmdoc_command)
else:
self._generate_individual(invalid_targets, create_jvmdoc_command)

if self.open and self.combined:
try:
desktop.ui_open(os.path.join(self.workdir, 'combined', 'index.html'))
except desktop.OpenError as e:
raise TaskError(e)

if catalog:
for target in targets:
Expand All @@ -142,11 +149,6 @@ def _generate_combined(self, targets, create_jvmdoc_command):
self.context.log.debug("Running create_jvmdoc in {} with {}".format(gendir, " ".join(command)))
result, gendir = create_jvmdoc(command, gendir)
self._handle_create_jvmdoc_result(targets, result, command)
if self.open:
try:
desktop.ui_open(os.path.join(gendir, 'index.html'))
except desktop.OpenError as e:
raise TaskError(e)

def _generate_individual(self, targets, create_jvmdoc_command):
jobs = {}
Expand Down

0 comments on commit 454ce5e

Please sign in to comment.