Group classpath products by their targets

Review Request #3338 — Created Jan. 14, 2016 and submitted

peiyu
pants
2807
3329
pants-reviews
nhoward_tw, patricklaw, stuhood, zundel

This review adds the convenient method get_product_target_mappings_for_targets,
to UnionProducts and ClasspathProducts to return products or classpath
products associated with their targets.

This is so that we can look up products for the targets their belong to.

Background:

https://rbcommons.com/s/twitter/r/3329/ attempts to create 3rdparty libraries
symlinks same way as internal libraries are created, for bundle. There are two
options:

  1. get the classpath products for all targets in binary.closure(bfs=True) in
    one call get_classpath_entries_for_targets
  2. make the same call multiple times for each target

The issue with (2) is it does not respect the excludes same as (1), because
excludes are transitive to their dependents.

This review will allow us after calling get_classpath_entries_for_targets,
get products' target.id for each products and make symlinks accordingly.

https://travis-ci.org/peiyuwang/pants/builds/102419914

ST
  1. Thanks Peiyu.

    because excludes are global.

    More specifically, excludes are transitive to their dependents.

    1. fixed description

  2. I think the comment is incorrect. The dict groups by product, with the list of targets providing that product..?

  3. src/python/pants/goal/products.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     

    Rather than grouping these in ordered dictionaries here, it seems like it might be easier to return them as tuples of (product, target), and to then let callers do the group if they want to.

    1. this is easier for existing code to call get_for_targets can be just get_for_targets_by_product(targets).keys(), so i migrated the former to use the latter.

      one thing i am completely sure is the performance, seems more work using the new method, but hopefully not too much.

    2. Changed now

  4. 
      
PE
PE
PE
Review request changed

Status: Closed (submitted)

Change Summary:

Committed at 6969355d38be62bb8f7deb753940f554e433a2fb

Loading...