buildSrc/src/main/java/com/uber/okbuck/core/task/OkBuckCleanTask.java [36:97]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  void clean() throws IOException {
    Project rootProject = getProject();
    Path rootProjectPath = rootProject.getProjectDir().toPath();

    File okbuckState = rootProject.file(OkBuckGradlePlugin.OKBUCK_STATE);

    // Get last project paths
    Set<String> lastProjectPaths;
    if (okbuckState.exists()) {
      try (Stream<String> lines = Files.lines(okbuckState.toPath())) {
        lastProjectPaths =
            lines
                .map(String::trim)
                .filter(s -> !Strings.isNullOrEmpty(s))
                .collect(MoreCollectors.toImmutableSet());
      }
    } else {
      lastProjectPaths = ImmutableSet.of();
      okbuckState.getParentFile().mkdirs();
      okbuckState.createNewFile();
    }

    Set<String> currentProjectPaths =
        projects
            .stream()
            .filter(project -> ProjectUtil.getType(project) != ProjectType.UNKNOWN)
            .map(
                project ->
                    project
                        .getRootProject()
                        .getProjectDir()
                        .toPath()
                        .relativize(project.getProjectDir().toPath())
                        .toString())
            .collect(MoreCollectors.toImmutableSet());

    Sets.SetView<String> difference = Sets.difference(lastProjectPaths, currentProjectPaths);

    // Delete stale project's build file
    difference
        .stream()
        .map(
            p ->
                rootProjectPath
                    .resolve(p)
                    .resolve(ProjectUtil.getOkBuckExtension(rootProject).buildFileName))
        .forEach(FileUtil::deleteQuietly);

    // Delete old .okbuck/cache dir
    FileUtil.deleteQuietly(rootProjectPath.resolve(".okbuck/cache"));

    // Delete old .okbuck/gen dir
    FileUtil.deleteQuietly(rootProjectPath.resolve(".okbuck/gen"));

    // Delete old .buckconfig.local
    FileUtil.deleteQuietly(rootProjectPath.resolve(".buckconfig.local"));

    // Save generated project's build file path
    Files.write(
        okbuckState.toPath(),
        currentProjectPaths.stream().sorted().collect(MoreCollectors.toImmutableList()));
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



plugin/src/main/java/com/uber/okbuck/core/task/OkBuckCleanTask.java [36:97]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  void clean() throws IOException {
    Project rootProject = getProject();
    Path rootProjectPath = rootProject.getProjectDir().toPath();

    File okbuckState = rootProject.file(OkBuckGradlePlugin.OKBUCK_STATE);

    // Get last project paths
    Set<String> lastProjectPaths;
    if (okbuckState.exists()) {
      try (Stream<String> lines = Files.lines(okbuckState.toPath())) {
        lastProjectPaths =
            lines
                .map(String::trim)
                .filter(s -> !Strings.isNullOrEmpty(s))
                .collect(MoreCollectors.toImmutableSet());
      }
    } else {
      lastProjectPaths = ImmutableSet.of();
      okbuckState.getParentFile().mkdirs();
      okbuckState.createNewFile();
    }

    Set<String> currentProjectPaths =
        projects
            .stream()
            .filter(project -> ProjectUtil.getType(project) != ProjectType.UNKNOWN)
            .map(
                project ->
                    project
                        .getRootProject()
                        .getProjectDir()
                        .toPath()
                        .relativize(project.getProjectDir().toPath())
                        .toString())
            .collect(MoreCollectors.toImmutableSet());

    Sets.SetView<String> difference = Sets.difference(lastProjectPaths, currentProjectPaths);

    // Delete stale project's build file
    difference
        .stream()
        .map(
            p ->
                rootProjectPath
                    .resolve(p)
                    .resolve(ProjectUtil.getOkBuckExtension(rootProject).buildFileName))
        .forEach(FileUtil::deleteQuietly);

    // Delete old .okbuck/cache dir
    FileUtil.deleteQuietly(rootProjectPath.resolve(".okbuck/cache"));

    // Delete old .okbuck/gen dir
    FileUtil.deleteQuietly(rootProjectPath.resolve(".okbuck/gen"));

    // Delete old .buckconfig.local
    FileUtil.deleteQuietly(rootProjectPath.resolve(".buckconfig.local"));

    // Save generated project's build file path
    Files.write(
        okbuckState.toPath(),
        currentProjectPaths.stream().sorted().collect(MoreCollectors.toImmutableList()));
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



