code: def shade_jar(self, shading_rules, jar_path):
      
      self.context.log.debug('Shading {}.'.format(jar_path))
      with temporary_dir() as tempdir:
        output_jar = os.path.join(tempdir, os.path.basename(jar_path))
        with self.shader.binary_shader_for_rules(output_jar, jar_path, shading_rules) as shade_runner:
          result = execute_runner(shade_runner, workunit_factory=self.context.new_workunit,
                                  workunit_name='jarjar')
          if result != 0:
            raise TaskError('Shading tool failed to shade {0} (error code {1})'.format(jar_path,
                                                                                       result))
          if not os.path.exists(output_jar):
            raise TaskError('Shading tool returned success for {0}, but '
                            'the output jar was not found at {1}'.format(jar_path, output_jar))
          atomic_copy(output_jar, jar_path)
          return jar_path
docs: Shades a jar using the shading rules from the given jvm_binary.
  
      This *overwrites* the existing jar file at ``jar_path``.
  
      :param shading_rules: predefined rules for shading
      :param jar_path: The filepath to the jar that should be shaded.