<commit_before>import sbt._
import Keys._
import sbtassembly.Plugin._
import AssemblyKeys._

object build extends Build {
  lazy val ScalaVersion = "2.11.7"
  lazy val LibraryVersion = "0.1.0-SNAPSHOT"

  lazy val root = Project(
    id = "root",
    base = file("root")
  ) settings (
    sharedSettings : _*
  ) settings (
    packagedArtifacts := Map.empty
  ) aggregate (
    foundation,
    dialects,
    exceptions,
    interactive,
    parsers,
    prettyprinters,
    quasiquotes,
    scalameta,
    semantic,
    taxonomic,
    tokenizers,
    tokenquasiquotes,
    tql,
    trees,
    scalahost
  )

  lazy val foundation = Project(
    id   = "foundation",
    base = file("foundation")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's fundamental helpers and utilities",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  )

  lazy val dialects = Project(
    id   = "dialects",
    base = file("scalameta/dialects")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's dialects",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  ) dependsOn (foundation, exceptions)

  lazy val exceptions = Project(
    id   = "exceptions",
    base = file("scalameta/exceptions")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's baseline exceptions"
  ) dependsOn (foundation)

  lazy val interactive = Project(
    id   = "interactive",
    base = file("scalameta/interactive")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's APIs for interactive environments (REPLs, IDEs, ...)"
  ) dependsOn (foundation, exceptions, taxonomic)

  lazy val parsers = Project(
    id   = "parsers",
    base = file("scalameta/parsers")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's default implementation of the Parse[T] typeclass"
  ) dependsOn (foundation, exceptions, trees, tokens, tokenizers % "test", tql % "test")

  lazy val prettyprinters = Project(
    id   = "prettyprinters",
    base = file("scalameta/prettyprinters")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's baseline prettyprinters"
  ) dependsOn (foundation, exceptions)

  lazy val quasiquotes = Project(
    id   = "quasiquotes",
    base = file("scalameta/quasiquotes")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's quasiquotes for abstract syntax trees"
  ) dependsOn (foundation, exceptions, tokens, trees, parsers)

  lazy val semantic = Project(
    id   = "semantic",
    base = file("scalameta/semantic")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's APIs for traversing semantic structure of Scala programs"
  ) dependsOn (foundation, exceptions, prettyprinters, tokens, trees, taxonomic)

  lazy val taxonomic = Project(
    id   = "taxonomic",
    base = file("scalameta/taxonomic")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's APIs for traversing organizational structure of the Scala ecosystem",
    libraryDependencies += "org.apache.ivy" % "ivy" % "2.4.0"
  ) dependsOn (foundation, exceptions, trees, parsers)

  lazy val tokenizers = Project(
    id   = "tokenizers",
    base = file("scalameta/tokenizers")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's default implementation of the Tokenize typeclass",
    // TODO: This is a major embarassment: we need scalac's parser to parse xml literals,
    // because it was too hard to implement the xml literal parser from scratch.
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-compiler" % _)
  ) dependsOn (foundation, exceptions, tokens)

  lazy val tokenquasiquotes = Project(
    id   = "tokenquasiquotes",
    base = file("scalameta/tokenquasiquotes")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's quasiquotes for tokens",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  ) dependsOn (foundation, exceptions, tokens, tokenizers)

  lazy val tokens = Project(
    id   = "tokens",
    base = file("scalameta/tokens")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's tokens and token-based abstractions (inputs and positions)",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  ) dependsOn (foundation, exceptions, prettyprinters, dialects)

  lazy val tql = Project(
    id   = "tql",
    base = file("scalameta/tql")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's tree query language (basic and extended APIs)",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  ) dependsOn (foundation, exceptions, trees)

  lazy val trees = Project(
    id   = "trees",
    base = file("scalameta/trees")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's abstract syntax trees",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  ) dependsOn (foundation, exceptions, prettyprinters, tokens, tokenquasiquotes)

  lazy val scalameta = Project(
    id   = "scalameta",
    base = file("scalameta/scalameta")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's metaprogramming and hosting APIs"
  ) dependsOn (foundation, exceptions, dialects, interactive, parsers, prettyprinters, quasiquotes, semantic, taxonomic, tokenizers, tokenquasiquotes, tql, trees)

  lazy val scalahost = Project(
    id   = "scalahost",
    base = file("scalahost")
  ) settings (
    publishableSettings: _*
  ) settings (
    mergeSettings: _*
  ) settings (
    crossVersion := CrossVersion.full,
    description := "Scalac-based host that implements scala.meta's hosting APIs",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-compiler" % _)
  ) settings (
    exposeClasspaths("scalahost"): _*
  ) dependsOn (scalameta)

  lazy val sharedSettings = Defaults.defaultSettings ++ Seq(
    scalaVersion := ScalaVersion,
    crossVersion := CrossVersion.binary,
    version := LibraryVersion,
    organization := "org.scalameta",
    resolvers += Resolver.sonatypeRepo("snapshots"),
    resolvers += Resolver.sonatypeRepo("releases"),
    addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full),
    libraryDependencies += "org.scalatest" %% "scalatest" % "2.1.3" % "test",
    libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.11.3" % "test",
    publishMavenStyle := true,
    publishArtifact in Compile := false,
    publishArtifact in Test := false,
    scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked"),
    scalacOptions in (Compile, doc) ++= Seq("-skip-packages", "scala.meta.internal.ast:scala.meta.internal.semantic:scala.meta.internal.tql"),
    scalacOptions in (Compile, doc) ++= Seq("-implicits", "-implicits-hide:.,scala.meta.syntactic.Api.XtensionInputLike,scala.meta.ui.Api.XtensionShow"),
    scalacOptions in (Compile, doc) ++= Seq("-groups"),
    scalacOptions in Test ++= Seq("-Xfatal-warnings"),
    parallelExecution in Test := false, // hello, reflection sync!!
    logBuffered := false,
    scalaHome := {
      val scalaHome = System.getProperty("core.scala.home")
      if (scalaHome != null) {
        println(s"Going for custom scala home at $scalaHome")
        Some(file(scalaHome))
      } else None
    },
    publishMavenStyle := true,
    publishOnlyWhenOnMaster := publishOnlyWhenOnMasterImpl.value,
    publishTo <<= version { v: String =>
      val nexus = "https://oss.sonatype.org/"
      if (v.trim.endsWith("SNAPSHOT"))
        Some("snapshots" at nexus + "content/repositories/snapshots")
      else
        Some("releases" at nexus + "service/local/staging/deploy/maven2")
    },
    pomIncludeRepository := { x => false },
    pomExtra := (
      <url>https://github.com/scalameta/scalameta</url>
      <inceptionYear>2014</inceptionYear>
      <licenses>
        <license>
          <name>BSD-like</name>
          <url>https://github.com/scalameta/scalameta/blob/master/LICENSE.md</url>
          <distribution>repo</distribution>
        </license>
      </licenses>
      <scm>
        <url>git://github.com/scalameta/scalameta.git</url>
        <connection>scm:git:git://github.com/scalameta/scalameta.git</connection>
      </scm>
      <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/scalameta/scalameta/issues</url>
      </issueManagement>
      <developers>
        <developer>
          <id>xeno-by</id>
          <name><NAME></name>
          <url>http://xeno.by</url>
        </developer>
        <developer>
          <id>densh</id>
          <name><NAME></name>
          <url>http://den.sh</url>
        </developer>
      </developers>
    )
  )

  lazy val publishableSettings = sharedSettings ++ Seq(
    publishArtifact in Compile := true,
    publishArtifact in Test := false,
    credentials ++= {
      val mavenSettingsFile = System.getProperty("maven.settings.file")
      if (mavenSettingsFile != null) {
        println("Loading Sonatype credentials from " + mavenSettingsFile)
        try {
          import scala.xml._
          val settings = XML.loadFile(mavenSettingsFile)
          def readServerConfig(key: String) = (settings \\ "settings" \\ "servers" \\ "server" \\ key).head.text
          Some(Credentials(
            "Sonatype Nexus Repository Manager",
            "oss.sonatype.org",
            readServerConfig("username"),
            readServerConfig("password")
          ))
        } catch {
          case ex: Exception =>
            println("Failed to load Maven settings from " + mavenSettingsFile + ": " + ex)
            None
        }
      } else {
        for {
          realm <- sys.env.get("SCALAMETA_MAVEN_REALM")
          domain <- sys.env.get("SCALAMETA_MAVEN_DOMAIN")
          user <- sys.env.get("SCALAMETA_MAVEN_USER")
          password <- sys.env.get("SCALAMETA_MAVEN_PASSWORD")
        } yield {
          println("Loading Sonatype credentials from environment variables")
          Credentials(realm, domain, user, password)
        }
      }
    }.toList
  )

  // http://stackoverflow.com/questions/20665007/how-to-publish-only-when-on-master-branch-under-travis-and-sbt-0-13
  lazy val publishOnlyWhenOnMaster = taskKey[Unit]("publish task for Travis (don't publish when building pull requests, only publish when the build is triggered by merge into master)")
  def publishOnlyWhenOnMasterImpl = Def.taskDyn {
    import scala.util.Try
    val travis   = Try(sys.env("TRAVIS")).getOrElse("false") == "true"
    val pr       = Try(sys.env("TRAVIS_PULL_REQUEST")).getOrElse("false") != "false"
    val branch   = Try(sys.env("TRAVIS_BRANCH")).getOrElse("??")
    val snapshot = version.value.trim.endsWith("SNAPSHOT")
    (travis, pr, branch, snapshot) match {
      case (true, false, "master", true) => publish
      case _                             => Def.task ()
    }
  }

  lazy val mergeSettings: Seq[sbt.Def.Setting[_]] = assemblySettings ++ Seq(
    test in assembly := {},
    logLevel in assembly := Level.Error,
    jarName in assembly := name.value + "_" + scalaVersion.value + "-" + version.value + "-assembly.jar",
    assemblyOption in assembly ~= { _.copy(includeScala = false) },
    Keys.`package` in Compile := {
      val slimJar = (Keys.`package` in Compile).value
      val fatJar = new File(crossTarget.value + "/" + (jarName in assembly).value)
      val _ = assembly.value
      IO.copy(List(fatJar -> slimJar), overwrite = true)
      slimJar
    },
    packagedArtifact in Compile in packageBin := {
      val temp = (packagedArtifact in Compile in packageBin).value
      val (art, slimJar) = temp
      val fatJar = new File(crossTarget.value + "/" + (jarName in assembly).value)
      val _ = assembly.value
      IO.copy(List(fatJar -> slimJar), overwrite = true)
      (art, slimJar)
    }
  )

  def exposeClasspaths(projectName: String) = Seq(
    sourceDirectory in Test := {
      val defaultValue = (sourceDirectory in Test).value
      System.setProperty("sbt.paths." + projectName + ".sources", defaultValue.getAbsolutePath)
      defaultValue
    },
    resourceDirectory in Test := {
      val defaultValue = (resourceDirectory in Test).value
      System.setProperty("sbt.paths." + projectName + ".resources", defaultValue.getAbsolutePath)
      defaultValue
    },
    fullClasspath in Test := {
      val defaultValue = (fullClasspath in Test).value
      val classpath = defaultValue.files.map(_.getAbsolutePath)
      val scalaLibrary = classpath.map(_.toString).find(_.contains("scala-library")).get
      System.setProperty("sbt.paths.scalalibrary.classes", scalaLibrary)
      System.setProperty("sbt.paths." + projectName + ".classes", classpath.mkString(java.io.File.pathSeparator))
      defaultValue
    }
  )
}
<commit_msg>omg this was very annoying to debug<commit_after>import sbt._
import Keys._
import sbtassembly.Plugin._
import AssemblyKeys._

object build extends Build {
  lazy val ScalaVersion = "2.11.7"
  lazy val LibraryVersion = "0.1.0-SNAPSHOT"

  lazy val root = Project(
    id = "root",
    base = file("root")
  ) settings (
    sharedSettings : _*
  ) settings (
    packagedArtifacts := Map.empty
  ) aggregate (
    foundation,
    dialects,
    exceptions,
    interactive,
    parsers,
    prettyprinters,
    quasiquotes,
    scalameta,
    semantic,
    taxonomic,
    tokenizers,
    tokenquasiquotes,
    tokens,
    tql,
    trees,
    scalahost
  )

  lazy val foundation = Project(
    id   = "foundation",
    base = file("foundation")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's fundamental helpers and utilities",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  )

  lazy val dialects = Project(
    id   = "dialects",
    base = file("scalameta/dialects")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's dialects",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  ) dependsOn (foundation, exceptions)

  lazy val exceptions = Project(
    id   = "exceptions",
    base = file("scalameta/exceptions")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's baseline exceptions"
  ) dependsOn (foundation)

  lazy val interactive = Project(
    id   = "interactive",
    base = file("scalameta/interactive")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's APIs for interactive environments (REPLs, IDEs, ...)"
  ) dependsOn (foundation, exceptions, taxonomic)

  lazy val parsers = Project(
    id   = "parsers",
    base = file("scalameta/parsers")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's default implementation of the Parse[T] typeclass"
  ) dependsOn (foundation, exceptions, trees, tokens, tokenizers % "test", tql % "test")

  lazy val prettyprinters = Project(
    id   = "prettyprinters",
    base = file("scalameta/prettyprinters")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's baseline prettyprinters"
  ) dependsOn (foundation, exceptions)

  lazy val quasiquotes = Project(
    id   = "quasiquotes",
    base = file("scalameta/quasiquotes")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's quasiquotes for abstract syntax trees"
  ) dependsOn (foundation, exceptions, tokens, trees, parsers)

  lazy val semantic = Project(
    id   = "semantic",
    base = file("scalameta/semantic")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's APIs for traversing semantic structure of Scala programs"
  ) dependsOn (foundation, exceptions, prettyprinters, tokens, trees, taxonomic)

  lazy val taxonomic = Project(
    id   = "taxonomic",
    base = file("scalameta/taxonomic")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's APIs for traversing organizational structure of the Scala ecosystem",
    libraryDependencies += "org.apache.ivy" % "ivy" % "2.4.0"
  ) dependsOn (foundation, exceptions, trees, parsers)

  lazy val tokenizers = Project(
    id   = "tokenizers",
    base = file("scalameta/tokenizers")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's default implementation of the Tokenize typeclass",
    // TODO: This is a major embarassment: we need scalac's parser to parse xml literals,
    // because it was too hard to implement the xml literal parser from scratch.
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-compiler" % _)
  ) dependsOn (foundation, exceptions, tokens)

  lazy val tokenquasiquotes = Project(
    id   = "tokenquasiquotes",
    base = file("scalameta/tokenquasiquotes")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's quasiquotes for tokens",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  ) dependsOn (foundation, exceptions, tokens, tokenizers)

  lazy val tokens = Project(
    id   = "tokens",
    base = file("scalameta/tokens")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's tokens and token-based abstractions (inputs and positions)",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  ) dependsOn (foundation, exceptions, prettyprinters, dialects)

  lazy val tql = Project(
    id   = "tql",
    base = file("scalameta/tql")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's tree query language (basic and extended APIs)",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  ) dependsOn (foundation, exceptions, trees)

  lazy val trees = Project(
    id   = "trees",
    base = file("scalameta/trees")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's abstract syntax trees",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _ % "provided")
  ) dependsOn (foundation, exceptions, prettyprinters, tokens, tokenquasiquotes)

  lazy val scalameta = Project(
    id   = "scalameta",
    base = file("scalameta/scalameta")
  ) settings (
    publishableSettings: _*
  ) settings (
    description := "Scala.meta's metaprogramming and hosting APIs"
  ) dependsOn (foundation, exceptions, dialects, interactive, parsers, prettyprinters, quasiquotes, semantic, taxonomic, tokenizers, tokenquasiquotes, tql, trees)

  lazy val scalahost = Project(
    id   = "scalahost",
    base = file("scalahost")
  ) settings (
    publishableSettings: _*
  ) settings (
    mergeSettings: _*
  ) settings (
    crossVersion := CrossVersion.full,
    description := "Scalac-based host that implements scala.meta's hosting APIs",
    libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-compiler" % _)
  ) settings (
    exposeClasspaths("scalahost"): _*
  ) dependsOn (scalameta)

  lazy val sharedSettings = Defaults.defaultSettings ++ Seq(
    scalaVersion := ScalaVersion,
    crossVersion := CrossVersion.binary,
    version := LibraryVersion,
    organization := "org.scalameta",
    resolvers += Resolver.sonatypeRepo("snapshots"),
    resolvers += Resolver.sonatypeRepo("releases"),
    addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full),
    libraryDependencies += "org.scalatest" %% "scalatest" % "2.1.3" % "test",
    libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.11.3" % "test",
    publishMavenStyle := true,
    publishArtifact in Compile := false,
    publishArtifact in Test := false,
    scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked"),
    scalacOptions in (Compile, doc) ++= Seq("-skip-packages", "scala.meta.internal.ast:scala.meta.internal.semantic:scala.meta.internal.tql"),
    scalacOptions in (Compile, doc) ++= Seq("-implicits", "-implicits-hide:.,scala.meta.syntactic.Api.XtensionInputLike,scala.meta.ui.Api.XtensionShow"),
    scalacOptions in (Compile, doc) ++= Seq("-groups"),
    scalacOptions in Test ++= Seq("-Xfatal-warnings"),
    parallelExecution in Test := false, // hello, reflection sync!!
    logBuffered := false,
    scalaHome := {
      val scalaHome = System.getProperty("core.scala.home")
      if (scalaHome != null) {
        println(s"Going for custom scala home at $scalaHome")
        Some(file(scalaHome))
      } else None
    },
    publishMavenStyle := true,
    publishOnlyWhenOnMaster := publishOnlyWhenOnMasterImpl.value,
    publishTo <<= version { v: String =>
      val nexus = "https://oss.sonatype.org/"
      if (v.trim.endsWith("SNAPSHOT"))
        Some("snapshots" at nexus + "content/repositories/snapshots")
      else
        Some("releases" at nexus + "service/local/staging/deploy/maven2")
    },
    pomIncludeRepository := { x => false },
    pomExtra := (
      <url>https://github.com/scalameta/scalameta</url>
      <inceptionYear>2014</inceptionYear>
      <licenses>
        <license>
          <name>BSD-like</name>
          <url>https://github.com/scalameta/scalameta/blob/master/LICENSE.md</url>
          <distribution>repo</distribution>
        </license>
      </licenses>
      <scm>
        <url>git://github.com/scalameta/scalameta.git</url>
        <connection>scm:git:git://github.com/scalameta/scalameta.git</connection>
      </scm>
      <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/scalameta/scalameta/issues</url>
      </issueManagement>
      <developers>
        <developer>
          <id>xeno-by</id>
          <name><NAME></name>
          <url>http://xeno.by</url>
        </developer>
        <developer>
          <id>densh</id>
          <name><NAME></name>
          <url>http://den.sh</url>
        </developer>
      </developers>
    )
  )

  lazy val publishableSettings = sharedSettings ++ Seq(
    publishArtifact in Compile := true,
    publishArtifact in Test := false,
    credentials ++= {
      val mavenSettingsFile = System.getProperty("maven.settings.file")
      if (mavenSettingsFile != null) {
        println("Loading Sonatype credentials from " + mavenSettingsFile)
        try {
          import scala.xml._
          val settings = XML.loadFile(mavenSettingsFile)
          def readServerConfig(key: String) = (settings \\ "settings" \\ "servers" \\ "server" \\ key).head.text
          Some(Credentials(
            "Sonatype Nexus Repository Manager",
            "oss.sonatype.org",
            readServerConfig("username"),
            readServerConfig("password")
          ))
        } catch {
          case ex: Exception =>
            println("Failed to load Maven settings from " + mavenSettingsFile + ": " + ex)
            None
        }
      } else {
        for {
          realm <- sys.env.get("SCALAMETA_MAVEN_REALM")
          domain <- sys.env.get("SCALAMETA_MAVEN_DOMAIN")
          user <- sys.env.get("SCALAMETA_MAVEN_USER")
          password <- sys.env.get("<PASSWORD>_MAVEN_PASSWORD")
        } yield {
          println("Loading Sonatype credentials from environment variables")
          Credentials(realm, domain, user, password)
        }
      }
    }.toList
  )

  // http://stackoverflow.com/questions/20665007/how-to-publish-only-when-on-master-branch-under-travis-and-sbt-0-13
  lazy val publishOnlyWhenOnMaster = taskKey[Unit]("publish task for Travis (don't publish when building pull requests, only publish when the build is triggered by merge into master)")
  def publishOnlyWhenOnMasterImpl = Def.taskDyn {
    import scala.util.Try
    val travis   = Try(sys.env("TRAVIS")).getOrElse("false") == "true"
    val pr       = Try(sys.env("TRAVIS_PULL_REQUEST")).getOrElse("false") != "false"
    val branch   = Try(sys.env("TRAVIS_BRANCH")).getOrElse("??")
    val snapshot = version.value.trim.endsWith("SNAPSHOT")
    (travis, pr, branch, snapshot) match {
      case (true, false, "master", true) => publish
      case _                             => Def.task ()
    }
  }

  lazy val mergeSettings: Seq[sbt.Def.Setting[_]] = assemblySettings ++ Seq(
    test in assembly := {},
    logLevel in assembly := Level.Error,
    jarName in assembly := name.value + "_" + scalaVersion.value + "-" + version.value + "-assembly.jar",
    assemblyOption in assembly ~= { _.copy(includeScala = false) },
    Keys.`package` in Compile := {
      val slimJar = (Keys.`package` in Compile).value
      val fatJar = new File(crossTarget.value + "/" + (jarName in assembly).value)
      val _ = assembly.value
      IO.copy(List(fatJar -> slimJar), overwrite = true)
      slimJar
    },
    packagedArtifact in Compile in packageBin := {
      val temp = (packagedArtifact in Compile in packageBin).value
      val (art, slimJar) = temp
      val fatJar = new File(crossTarget.value + "/" + (jarName in assembly).value)
      val _ = assembly.value
      IO.copy(List(fatJar -> slimJar), overwrite = true)
      (art, slimJar)
    }
  )

  def exposeClasspaths(projectName: String) = Seq(
    sourceDirectory in Test := {
      val defaultValue = (sourceDirectory in Test).value
      System.setProperty("sbt.paths." + projectName + ".sources", defaultValue.getAbsolutePath)
      defaultValue
    },
    resourceDirectory in Test := {
      val defaultValue = (resourceDirectory in Test).value
      System.setProperty("sbt.paths." + projectName + ".resources", defaultValue.getAbsolutePath)
      defaultValue
    },
    fullClasspath in Test := {
      val defaultValue = (fullClasspath in Test).value
      val classpath = defaultValue.files.map(_.getAbsolutePath)
      val scalaLibrary = classpath.map(_.toString).find(_.contains("scala-library")).get
      System.setProperty("sbt.paths.scalalibrary.classes", scalaLibrary)
      System.setProperty("sbt.paths." + projectName + ".classes", classpath.mkString(java.io.File.pathSeparator))
      defaultValue
    }
  )
}

{'fraction_non_alphanumeric': 0.12896294341614203, 'fraction_numerical': 0.0027896105854412485, 'mean_word_length': 3.1141439205955335, 'pattern_counts': {'":': 2, '<': 124, '<?xml version=': 0, '>': 110, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4359385', 'n_tokens_mistral': 8397, 'n_tokens_neox': 8103, 'n_words': 1803}