Have SourcesField handle the calculation of SourceRoots

Review Request #3230 - Created Dec. 11, 2015 and submitted

Information
Stu Hood
pants
2688
Reviewers
pants-reviews
benjyw, peiyu, zundel

We're killing some old code internally that extends IvyTaskMixin, and having it use UnpackedJars instead. During the course of that, I noticed that source_roots were not getting registered correctly for all generated code; particularly deferred sources.

There were twoish issues: simple_codegen_task was adding absolute sourceroots, which would not match anything later, and in order for deferred sources to have a valid source root, it needed the source root to be rooted where its sources lived (under .pants.d), rather than at its own target address.

  • Move SourcesField to the source package in order to allow it to more easily have a dep on the SourceRoots object
  • Remove FilesetWithSpec dependency from assert_list and remove validation's dependency on the source package
  • Use the null-object pattern with SourcesField by adding EmptySourcesField to answer has_sources and globs_relative_to_buildroot
  • Add def source_root to SourcesField, and use the rel_path of the sources to do source_root lookups, rather than the target address
  • Fix issue in source_root.py where add_source_root was adding absolute paths rather than relative paths, which caused the addition of source roots in simple_codegen_task to be a noop

https://travis-ci.org/pantsbuild/pants/builds/99189335

also manually validated that this allows us to use deferred_sources/unpacked_jars with scrooge

Issues

  • 0
  • 2
  • 0
  • 2
Description From Last Updated
Stu Hood
Eric Ayers
Benjy Weinberger
Stu Hood
Stu Hood
Eric Ayers
Patrick Lawson
Stu Hood
Stu Hood
Review request changed

Status: Closed (submitted)

Change Summary:

Merged as 2c68fc2c8ad84dea08041cd07e7968263aa41e39

Loading...