def register_android_tool(self, tool_path, workdir=None):
    """Return the full path for the tool at SDK location tool_path or of a copy under workdir.

    All android tasks should request their tools using this method.
    :param string tool_path: Path to tool, relative to the Android SDK root, e.g
      'platforms/android-19/android.jar'.
    :param string workdir: Location for the copied file. Pants will put a copy of the
      android file under workdir.
    :return: Full path to either the tool or a created copy of that tool.
    :rtype: string
    :raises: ``DistributionError`` if tool cannot be found.
    """
    if tool_path not in self._validated_tools:
      android_tool = self._get_tool_path(tool_path)
      # If an android file is bound for the classpath it must be under buildroot, so create a copy.
      if workdir:
        copy_path = os.path.join(workdir, tool_path)
        if not os.path.isfile(copy_path):
          try:
            safe_mkdir(os.path.dirname(copy_path))
            shutil.copy(android_tool, copy_path)
          except OSError as e:
            raise self.DistributionError('Problem creating copy of the android tool: {}'.format(e))
        self._validated_tools[tool_path] = copy_path
      else:
        self._validated_tools[tool_path] = android_tool
    return self._validated_tools[tool_path]
dataset/ETHPy150Open pantsbuild/pants/contrib/android/src/python/pants/contrib/android/distribution/android_distribution.py/AndroidDistribution.register_android_tool/original