@Override
  public SkyValue fetch(Rule rule, Path outputDirectory, Environment env)
      throws SkyFunctionException {
    prepareLocalRepositorySymlinkTree(rule, outputDirectory);
    PathFragment pathFragment = getTargetPath(rule, getWorkspace());

    if (!symlinkLocalRepositoryContents(
        outputDirectory, getOutputBase().getFileSystem().getPath(pathFragment))) {
      return null;
    }

    AttributeMap attributes = NonconfigurableAttributeMapper.of(rule);
    String buildToolsVersion = attributes.get("build_tools_version", Type.STRING);
    Integer apiLevel = attributes.get("api_level", Type.INTEGER);

    String template = getStringResource("android_sdk_repository_template.txt");

    String buildFile =
        template
            .replaceAll("%repository_name%", rule.getName())
            .replaceAll("%build_tools_version%", buildToolsVersion)
            .replaceAll("%api_level%", apiLevel.toString());

    writeBuildFile(outputDirectory, buildFile);
    return RepositoryDirectoryValue.create(outputDirectory);
  }
 @Override
 public SkyValue fetch(
     Rule rule, Path outputDirectory, BlazeDirectories directories, Environment env)
     throws SkyFunctionException {
   createDirectory(outputDirectory, rule);
   GitCloner.clone(rule, outputDirectory, env.getListener());
   return RepositoryDirectoryValue.create(outputDirectory);
 }