nodes: 0, module; 1, function_definition; 2, function_name:register_jvm_tool; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:register; 7, identifier:key; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, default_parameter; 16, expression_statement; 17, function_definition; 18, expression_statement; 19, expression_statement; 20, comment:# TODO(John Sirois): Move towards requiring tool specs point to jvm_binary targets.; 21, comment:# These already have a main and are a natural place to house any custom shading rules.  That; 22, comment:# would eliminate the need to pass main and custom_rules here.; 23, comment:# It is awkward that jars can no longer be inlined as dependencies - this will require 2 targets; 24, comment:# for every tool - the jvm_binary, and a jar_library for its dependencies to point to.  It may; 25, comment:# be worth creating a JarLibrary subclass - say JarBinary, or else mixing in a Binary interface; 26, comment:# to JarLibrary to endow it with main and shade_rules attributes to allow for single-target; 27, comment:# definition of resolvable jvm binaries.; 28, expression_statement; 29, expression_statement; 30, identifier:classpath_spec; 31, None; 32, identifier:main; 33, None; 34, identifier:custom_rules; 35, None; 36, identifier:fingerprint; 37, True; 38, identifier:classpath; 39, None; 40, identifier:help; 41, None; 42, identifier:removal_version; 43, None; 44, identifier:removal_hint; 45, None; 46, comment:"""Registers a jvm tool under `key` for lazy classpath resolution.
  
      Classpaths can be retrieved in `execute` scope via `tool_classpath_from_products`.
  
      NB: If the tool's `main` class name is supplied the tool classpath will be shaded.
  
      :param register: A function that can register options with the option system.
      :param unicode key: The key the tool configuration should be registered under.
      :param unicode classpath_spec: The tool classpath target address spec that can be used to
                                     override this tool's classpath; by default, `//:[key]`.
      :param unicode main: The fully qualified class name of the tool's main class if shading of the
                           tool classpath is desired.
      :param list custom_rules: An optional list of `Shader.Rule`s to apply before the automatically
                                generated binary jar shading rules.  This is useful for excluding
                                classes shared between the tool and the code it runs over.  The
                                canonical example is the `org.junit.Test` annotation read by junit
                                runner tools from user code. In this sort of case the shared code must
                                have a uniform name between the tool and the user code and so the
                                shared code must be excluded from shading.
      :param bool fingerprint: Indicates whether to include the jvm tool in the task's fingerprint.
                               Note that unlike for other options, fingerprinting is enabled for tools
                               by default.
      :param list classpath: A list of one or more `JarDependency` objects that form this tool's
                             default classpath.  If the classpath is optional, supply an empty list;
                             otherwise the default classpath of `None` indicates the `classpath_spec`
                             must point to a target defined in a BUILD file that provides the tool
                             classpath.
      :param unicode help: An optional custom help string; otherwise a reasonable one is generated.
      :param string removal_version: A semver at which this tool will be removed.
      :param unicode removal_hint: A hint on how to migrate away from this tool.
      """; 47, function_name:formulate_help; 48, parameters; 49, block; 50, assignment; 51, call; 52, assignment; 53, call; 54, if_statement; 55, identifier:help; 56, boolean_operator; 57, identifier:register; 58, argument_list; 59, identifier:jvm_tool; 60, call; 61, attribute; 62, argument_list; 63, identifier:classpath; 64, block; 65, else_clause; 66, identifier:help; 67, call; 68, call; 69, keyword_argument; 70, keyword_argument; 71, keyword_argument; 72, keyword_argument; 73, keyword_argument; 74, keyword_argument; 75, keyword_argument; 76, attribute; 77, argument_list; 78, attribute; 79, identifier:append; 80, identifier:jvm_tool; 81, return_statement; 82, block; 83, identifier:formulate_help; 84, argument_list; 85, attribute; 86, argument_list; 87, identifier:advanced; 88, True; 89, identifier:type; 90, identifier:target_option; 91, identifier:default; 92, conditional_expression:'//:{}'.format(key) if classpath_spec is None else classpath_spec; 93, identifier:help; 94, identifier:help; 95, identifier:fingerprint; 96, identifier:fingerprint; 97, identifier:removal_version; 98, identifier:removal_version; 99, identifier:removal_hint; 100, identifier:removal_hint; 101, identifier:cls; 102, identifier:JvmTool; 103, attribute; 104, identifier:key; 105, identifier:classpath; 106, identifier:main; 107, identifier:custom_rules; 108, identifier:JvmToolMixin; 109, identifier:_jvm_tools; 110, parenthesized_expression; 111, return_statement; 112, string; 113, identifier:format; 114, identifier:key; 115, call; 116, comparison_operator:classpath_spec is None; 117, identifier:classpath_spec; 118, identifier:register; 119, identifier:scope; 120, call; 121, call; 122, string_content:--{}; 123, attribute; 124, argument_list; 125, identifier:classpath_spec; 126, None; 127, attribute; 128, argument_list; 129, attribute; 130, argument_list; 131, string; 132, identifier:format; 133, identifier:key; 134, concatenated_string; 135, identifier:format; 136, identifier:key; 137, identifier:classpath; 138, string; 139, identifier:format; 140, identifier:key; 141, string_content://:{}; 142, string; 143, string; 144, string_content:Target address spec for specifying the classpath of the {} jvm tool.; 145, string_content:Target address spec for overriding the classpath of the {} jvm tool which is,; 146, string_content:by default: {}
code: def register_jvm_tool(cls,
                          register,
                          key,
                          classpath_spec=None,
                          main=None,
                          custom_rules=None,
                          fingerprint=True,
                          classpath=None,
                          help=None,
                          removal_version=None,
                          removal_hint=None):
      """Registers a jvm tool under `key` for lazy classpath resolution.
  
      Classpaths can be retrieved in `execute` scope via `tool_classpath_from_products`.
  
      NB: If the tool's `main` class name is supplied the tool classpath will be shaded.
  
      :param register: A function that can register options with the option system.
      :param unicode key: The key the tool configuration should be registered under.
      :param unicode classpath_spec: The tool classpath target address spec that can be used to
                                     override this tool's classpath; by default, `//:[key]`.
      :param unicode main: The fully qualified class name of the tool's main class if shading of the
                           tool classpath is desired.
      :param list custom_rules: An optional list of `Shader.Rule`s to apply before the automatically
                                generated binary jar shading rules.  This is useful for excluding
                                classes shared between the tool and the code it runs over.  The
                                canonical example is the `org.junit.Test` annotation read by junit
                                runner tools from user code. In this sort of case the shared code must
                                have a uniform name between the tool and the user code and so the
                                shared code must be excluded from shading.
      :param bool fingerprint: Indicates whether to include the jvm tool in the task's fingerprint.
                               Note that unlike for other options, fingerprinting is enabled for tools
                               by default.
      :param list classpath: A list of one or more `JarDependency` objects that form this tool's
                             default classpath.  If the classpath is optional, supply an empty list;
                             otherwise the default classpath of `None` indicates the `classpath_spec`
                             must point to a target defined in a BUILD file that provides the tool
                             classpath.
      :param unicode help: An optional custom help string; otherwise a reasonable one is generated.
      :param string removal_version: A semver at which this tool will be removed.
      :param unicode removal_hint: A hint on how to migrate away from this tool.
      """
      def formulate_help():
        if classpath:
          return ('Target address spec for overriding the classpath of the {} jvm tool which is, '
                  'by default: {}'.format(key, classpath))
        else:
          return 'Target address spec for specifying the classpath of the {} jvm tool.'.format(key)
      help = help or formulate_help()
  
      register('--{}'.format(key),
               advanced=True,
               type=target_option,
               default='//:{}'.format(key) if classpath_spec is None else classpath_spec,
               help=help,
               fingerprint=fingerprint,
               removal_version=removal_version,
               removal_hint=removal_hint)
  
      # TODO(John Sirois): Move towards requiring tool specs point to jvm_binary targets.
      # These already have a main and are a natural place to house any custom shading rules.  That
      # would eliminate the need to pass main and custom_rules here.
      # It is awkward that jars can no longer be inlined as dependencies - this will require 2 targets
      # for every tool - the jvm_binary, and a jar_library for its dependencies to point to.  It may
      # be worth creating a JarLibrary subclass - say JarBinary, or else mixing in a Binary interface
      # to JarLibrary to endow it with main and shade_rules attributes to allow for single-target
      # definition of resolvable jvm binaries.
      jvm_tool = cls.JvmTool(register.scope, key, classpath, main, custom_rules)
      JvmToolMixin._jvm_tools.append(jvm_tool)