Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix scala artifact merging bug.

  • Loading branch information...
commit 716e479d8781a6132ede4c522756fc4cf1bba39b 1 parent edd7c3e
Benjy authored
7 src/python/twitter/pants/tasks/scala/
@@ -150,7 +150,7 @@ def __init__(self, underlying_artifacts, factory , targets, sources_by_target,
classes_dir, analysis_file)
self.underlying_artifacts = underlying_artifacts
- def merge(self):
+ def merge(self, force=False):
"""Actually combines the underlying artifacts into a single merged one.
Creates a single merged analysis file and a single merged classes dir.
@@ -162,12 +162,12 @@ def merge(self):
# copying files around.
# Must merge analysis before computing current state.
- if not os.path.exists(self.analysis_file):
+ if force or not os.path.exists(self.analysis_file):
current_state = self.current_state()
- if not os.path.exists(self.classes_dir):
+ if force or not os.path.exists(self.classes_dir):
return current_state
@@ -204,6 +204,7 @@ def _merge_classes_dir(self, state):
if len(self.underlying_artifacts) <= 1:
self.log.debug('Merging classes dirs into %s' % self.classes_dir)
+ safe_rmtree(self.classes_dir)
symlinkable_packages = self._symlinkable_packages(state)
for artifact in self.underlying_artifacts:
classnames_by_package = defaultdict(list)
8 src/python/twitter/pants/tasks/
@@ -185,7 +185,13 @@ def _process_target_partition(self, vts, cp, upstream_analysis_map):
# We must do this even if we're not going to compile, because the merged output dir
# will go on the classpath of downstream tasks. We can't put the per-target dirs
# on the classpath because Zinc doesn't handle large numbers of upstream deps well.
- current_state = merged_artifact.merge()
+ current_state = merged_artifact.merge(force=not vts.valid)
+ # Note: vts.valid tells us if the merged artifact is valid. If not, we recreate it
+ # above. [not vt.valid for vt in vts.versioned_targets] tells us if anything needs
+ # to be recompiled. The distinction is important: all the underlying targets may be
+ # valid because they were built in some other pants run with different partitions,
+ # but this partition may still be invalid and need merging.
# Invoke the compiler if needed.
if any([not vt.valid for vt in vts.versioned_targets]):
Please sign in to comment.
Something went wrong with that request. Please try again.