Add support for ServiceLoader service providers.

Review Request #2331 - Created June 8, 2015 and submitted

Information
John Sirois
pants
jsirois/issues/1634
1634, 1647
b93df51...
Reviewers
pants-reviews
areitz, benjyw, jinfeng, zundel
Since ServiceLoader service providers are part of the jvm apis and we
support them already in the jar tool (concatenating service provider
configuration files by default when creating binaries), add support for
generating the service provider configuration files directly.

This change also refactors the existing `PrepareResources` class, moving
it from the core backend to jvm since it operated on jvm assumptions and
lifting its core machinery to a `ResourcesTask` base class.

 src/python/pants/backend/core/register.py                           |   4 -
 src/python/pants/backend/core/tasks/BUILD                           |  12 ---
 src/python/pants/backend/core/tasks/prepare_resources.py            |  95 -------------------
 src/python/pants/backend/jvm/register.py                            |   7 +-
 src/python/pants/backend/jvm/targets/jvm_target.py                  |  16 ++++
 src/python/pants/backend/jvm/tasks/BUILD                            |  66 ++++++++++----
 src/python/pants/backend/jvm/tasks/prepare_resources.py             |  69 ++++++++++++++
 src/python/pants/backend/jvm/tasks/prepare_services.py              |  57 ++++++++++++
 src/python/pants/backend/jvm/tasks/resources_task.py                | 120 ++++++++++++++++++++++++
 src/python/pants/backend/project_info/tasks/BUILD                   |   5 +-
 tests/python/pants_test/backend/jvm/tasks/BUILD                     |  44 +++++++++
 tests/python/pants_test/backend/jvm/tasks/test_prepare_resources.py | 102 +++++++++++++++++++++
 tests/python/pants_test/backend/jvm/tasks/test_prepare_services.py  | 153 +++++++++++++++++++++++++++++++
 tests/python/pants_test/backend/jvm/tasks/test_resources_task.py    | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++
 14 files changed, 865 insertions(+), 133 deletions(-)

New test coverage:

$ pants.dev test.pytest \
  --coverage=modules:pants.backend.jvm.tasks.resources_task,pants.backend.jvm.tasks.prepare_resources,pants.backend.jvm.tasks.prepare_services \
  tests/python/pants_test/backend/jvm/tasks/:{resources_task,prepare_{resources,services}}
...
13:28:02 00:01         [chroot]============== test session starts ===============
                     platform linux2 -- Python 2.7.8 -- py-1.4.28 -- pytest-2.6.4
                     plugins: timeout
                     collected 17 items 

                     tests/python/pants_test/backend/jvm/tasks/test_resources_task.py ......
                     tests/python/pants_test/backend/jvm/tasks/test_prepare_resources.py .....
                     tests/python/pants_test/backend/jvm/tasks/test_prepare_services.py ......

                     =========== 17 passed in 0.69 seconds ============
                     Name                                                   Stmts   Miss Branch BrMiss  Cover
                     ----------------------------------------------------------------------------------------
                     src/python/pants/backend/jvm/tasks/prepare_resources      32      2      6      0    95%
                     src/python/pants/backend/jvm/tasks/prepare_services       31      0      6      0   100%
                     src/python/pants/backend/jvm/tasks/resources_task         54      2     24      2    95%
                     ----------------------------------------------------------------------------------------
                     TOTAL                                                    117      4     36      2    96%
...

CI went green here:
https://travis-ci.org/pantsbuild/pants/builds/66066808

John Sirois
John Sirois
John Sirois
Andy Reitz
Eric Ayers
Mike Cripps
Benjy Weinberger
John Sirois
John Sirois
John Sirois
Review request changed

Status: Closed (submitted)

Loading...