Add optional support for auto-shading jvm tools.

Review Request #2052 - Created April 10, 2015 and submitted

Information
John Sirois
pants
jsirois/issues/663/shade_bootstrapped_tools
663, 1362, 1391
2050
02df941...
Reviewers
pants-reviews
benjyw, mateor, zundel
When registering a jvm tool, the main classname of the tool can be
specified to trigger auto-shading of the tool classpath.

This functionality is dogfooded by JUnitRun for its junit-runner tool.

This changes adds a test for bootstrap_jvm_tools.py that exercises the
normal (legacy) and shading paths as well as updating the
jvm_tool_task_test_base.py infra to work with this new shading option.
The latter enables the pre-existing JUnitRunTest to operate, now using
an auto-shaded jar.

 src/python/pants/backend/jvm/tasks/BUILD                              |   7 ++-
 src/python/pants/backend/jvm/tasks/bootstrap_jvm_tools.py             | 142 +++++++++++++++++++++++++++++++++++++++++++++-----
 src/python/pants/backend/jvm/tasks/jar_create.py                      |   9 +++-
 src/python/pants/backend/jvm/tasks/jar_task.py                        |  49 +++++++++--------
 src/python/pants/backend/jvm/tasks/junit_run.py                       |  10 +++-
 src/python/pants/backend/jvm/tasks/jvm_binary_task.py                 |   7 +--
 src/python/pants/backend/jvm/tasks/jvm_tool_task_mixin.py             |  47 ++++++++++++-----
 tests/python/pants_test/backend/jvm/tasks/BUILD                       |  16 ++++++
 tests/python/pants_test/backend/jvm/tasks/test_bootstrap_jvm_tools.py |  93 +++++++++++++++++++++++++++++++++
 tests/python/pants_test/backend/jvm/tasks/test_junit_run.py           |   3 +-
 tests/python/pants_test/jvm/jvm_tool_task_test_base.py                |  21 ++++++--
 tests/python/pants_test/tasks/test_jar_task.py                        |   4 +-
 12 files changed, 343 insertions(+), 65 deletions(-)

I manually tested shaded jar invalidation. It is costly (~6s for the
junit-runner tool), so having the invalidation work correctly is
important.

Decent coverage for the bulk of the new code:

$ PANTS_PY_COVERAGE=modules:pants.backend.jvm.tasks.bootstrap_jvm_tools pants.dev test tests/python/pants_test/backend/jvm/tasks:bootstrap_jvm_tools
...
02:29:21 00:00   [test]
02:29:21 00:00     [run_prep_command]
02:29:21 00:00     [test]
02:29:21 00:00     [pytest]
02:29:21 00:00       [run]
                     ============== test session starts ===============
                     platform linux2 -- Python 2.7.8 -- py-1.4.26 -- pytest-2.6.4
                     plugins: timeout
                     collected 1 items 

                     tests/python/pants_test/backend/jvm/tasks/test_bootstrap_jvm_tools.py .

                     =========== 1 passed in 10.86 seconds ============
                     Name                                                     Stmts   Miss Branch BrMiss  Cover
                     ------------------------------------------------------------------------------------------
                     src/python/pants/backend/jvm/tasks/bootstrap_jvm_tools     125     16     38     12    83%

02:29:34 00:13     [junit]
02:29:34 00:13     [specs]
               SUCCESS

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

John Sirois
John Sirois
Eric Ayers
Mateo Rodriguez
John Sirois
John Sirois
John Sirois
John Sirois
Review request changed

Status: Closed (submitted)

Loading...