<commit_before>package org.jetbrains.sbt

import java.io.{PrintWriter, FileWriter, File}
import scala.io.Source

/**
 * @author <NAME>
 */
object Loader {
  private val JavaVM = canonicalPath(new File(new File(new File(System.getProperty("java.home")), "bin"), "java"))
  private val SbtLauncher = canonicalPath(new File("sbt-launch.jar"))
  private val SbtPlugin = canonicalPath(new File("target/scala-2.9.2/sbt-0.12/classes/"))
  private val JavaOpts = Option(System.getenv("JAVA_OPTS")).map(_.split("\\s+")).toSeq.flatten

  def load(project: File, download: Boolean): Seq[String] = {
    val structureFile = createTempFile("sbt-structure", ".xml")
    val commandsFile = createTempFile("sbt-commands", ".lst")

    val className = if (download) "ReadProjectAndRepository" else "ReadProject"

    writeLinesTo(commandsFile,
      "set artifactPath := file(\"" + canonicalPath(structureFile) + "\")",
      "apply -cp " + SbtPlugin + " org.jetbrains.sbt." + className)

    val commands = JavaVM +: JavaOpts :+ "-jar" :+ SbtLauncher :+ ("< " + canonicalPath(commandsFile))

    run(commands, project)

    assert(structureFile.exists, "File must be created: " + structureFile.getPath)

    read(structureFile)
  }

  private def canonicalPath(file: File): String = file.getAbsolutePath.replace('\\', '/')

  private def createTempFile(prefix: String, suffix: String): File = {
    val file = File.createTempFile(prefix, suffix)
    file.deleteOnExit()
    file
  }

  private def writeLinesTo(file: File, lines: String*) {
    val writer = new PrintWriter(new FileWriter(file))
    lines.foreach(writer.println(_))
    writer.close()
  }

  private def run(commands: Seq[String], directory: File) {
    val process = Runtime.getRuntime.exec(commands.toArray, null, directory)
<commit_msg>Don't use JAVA_OPTS in tests<commit_after>package org.jetbrains.sbt

import java.io.{PrintWriter, FileWriter, File}
import scala.io.Source

/**
 * @author <NAME>
 */
object Loader {
  private val JavaVM = path(new File(new File(new File(System.getProperty("java.home")), "bin"), "java"))
  private val SbtLauncher = path(new File("sbt-launch.jar"))
  private val SbtPlugin = path(new File("target/scala-2.9.2/sbt-0.12/classes/"))

  def load(project: File, download: Boolean): Seq[String] = {
    val structureFile = createTempFile("sbt-structure", ".xml")
    val commandsFile = createTempFile("sbt-commands", ".lst")

    val className = if (download) "ReadProjectAndRepository" else "ReadProject"

    writeLinesTo(commandsFile,
      "set artifactPath := file(\"" + path(structureFile) + "\")",
      "apply -cp " + SbtPlugin + " org.jetbrains.sbt." + className)

    val commands = Seq(JavaVM, "-jar", SbtLauncher, "< " + path(commandsFile))

    run(commands, project)

    assert(structureFile.exists, "File must be created: " + structureFile.getPath)

    read(structureFile)
  }

  private def path(file: File): String = file.getAbsolutePath.replace('\\', '/')

  private def createTempFile(prefix: String, suffix: String): File = {
    val file = File.createTempFile(prefix, suffix)
    file.deleteOnExit()
    file
  }

  private def writeLinesTo(file: File, lines: String*) {
    val writer = new PrintWriter(new FileWriter(file))
    lines.foreach(writer.println(_))
    writer.close()
  }

  private def run(commands: Seq[String], directory: File) {
    val process = Runtime.getRuntime.exec(commands.toArray, null, directory)

{'fraction_non_alphanumeric': 0.1471874089186826, 'fraction_numerical': 0.0034975225881667153, 'mean_word_length': 4.247706422018348, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7246389', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1071, 'n_words': 249}