<commit_before>package com.google.closure.plugin.proto;

import java.io.File;
import java.io.IOException;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;

import com.google.closure.module.ClosureModule;
import com.google.closure.plugin.common.Ingredients.PathValue;
import com.google.closure.plugin.common.Ingredients.SerializedObjectIngredient;
import com.google.closure.plugin.plan.Ingredient;
import com.google.closure.plugin.plan.PlanKey;
import com.google.closure.plugin.plan.Step;
import com.google.closure.plugin.plan.StepSource;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.io.Files;

final class CopyProtosToJar extends Step {

  private static final String DESCRIPTORS_FILE_BASENAME =
      ClosureModule.PROTO_DESCRIPTORS_RESOURCE_PATH.substring(
          ClosureModule.PROTO_DESCRIPTORS_RESOURCE_PATH.lastIndexOf('/') + 1);

  CopyProtosToJar(
      PathValue closureOutputDirectory,
      SerializedObjectIngredient<ProtoIO> protoIO) {
    super(
        PlanKey.builder("copy-pd-to-jar").build(),
        ImmutableList.<Ingredient>of(closureOutputDirectory, protoIO),
        Sets.immutableEnumSet(StepSource.PROTO_DESCRIPTOR_SET),
        ImmutableSet.<StepSource>of());
  }

  @Override
  public void execute(Log log) throws MojoExecutionException {
    PathValue closureOutputDirectory = (PathValue) inputs.get(0);
    SerializedObjectIngredient<ProtoIO> protoIO =
        ((SerializedObjectIngredient<?>) inputs.get(1))
        .asSuperType(ProtoIO.class);

    File descriptorSetFile =
        protoIO.getStoredObject().get().mainDescriptorSetFile;
    if (descriptorSetFile.exists()) {
      // Not generated if protoc is not run.
      try {
        closureOutputDirectory.value.mkdir();
        Files.copy(
            descriptorSetFile,
            new File(closureOutputDirectory.value, DESCRIPTORS_FILE_BASENAME));
      } catch (IOException ex) {
        throw new MojoExecutionException(
            "Failed to copy proto descriptors to build output", ex);
      }
    }
  }

  @Override
  public void skip(Log log) throws MojoExecutionException {
    // Done
  }

  @Override
  public ImmutableList<Step> extraSteps(Log log) {
    return ImmutableList.of();<commit_msg>properly create directory for file descriptors: s/mkdir/mkdirs/<commit_after>package com.google.closure.plugin.proto;

import java.io.File;
import java.io.IOException;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;

import com.google.closure.module.ClosureModule;
import com.google.closure.plugin.common.Ingredients.PathValue;
import com.google.closure.plugin.common.Ingredients.SerializedObjectIngredient;
import com.google.closure.plugin.plan.Ingredient;
import com.google.closure.plugin.plan.PlanKey;
import com.google.closure.plugin.plan.Step;
import com.google.closure.plugin.plan.StepSource;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.io.Files;

final class CopyProtosToJar extends Step {

  private static final String DESCRIPTORS_FILE_BASENAME =
      ClosureModule.PROTO_DESCRIPTORS_RESOURCE_PATH.substring(
          ClosureModule.PROTO_DESCRIPTORS_RESOURCE_PATH.lastIndexOf('/') + 1);

  CopyProtosToJar(
      PathValue closureOutputDirectory,
      SerializedObjectIngredient<ProtoIO> protoIO) {
    super(
        PlanKey.builder("copy-pd-to-jar").build(),
        ImmutableList.<Ingredient>of(closureOutputDirectory, protoIO),
        Sets.immutableEnumSet(StepSource.PROTO_DESCRIPTOR_SET),
        ImmutableSet.<StepSource>of());
  }

  @Override
  public void execute(Log log) throws MojoExecutionException {
    PathValue closureOutputDirectory = (PathValue) inputs.get(0);
    SerializedObjectIngredient<ProtoIO> protoIO =
        ((SerializedObjectIngredient<?>) inputs.get(1))
        .asSuperType(ProtoIO.class);

    File descriptorSetFile =
        protoIO.getStoredObject().get().mainDescriptorSetFile;
    if (descriptorSetFile.exists()) {
      // Not generated if protoc is not run.
      try {
        closureOutputDirectory.value.mkdirs();
        Files.copy(
            descriptorSetFile,
            new File(closureOutputDirectory.value, DESCRIPTORS_FILE_BASENAME));
      } catch (IOException ex) {
        throw new MojoExecutionException(
            "Failed to copy proto descriptors to build output", ex);
      }
    }
  }

  @Override
  public void skip(Log log) throws MojoExecutionException {
    // Done
  }

  @Override
  public ImmutableList<Step> extraSteps(Log log) {
    return ImmutableList.of();
{'fraction_non_alphanumeric': 0.09876543209876543, 'fraction_numerical': 0.0012554927809165098, 'mean_word_length': 3.989561586638831, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5453603', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1399, 'n_words': 247}