<commit_before>import com.typesafe.sbt.SbtScalariform.{scalariformSettings => baseScalariformSettings, _}
import sbt._
import sbt.Keys._
import complete.Parsers.spaceDelimited
import sbtassembly.AssemblyKeys._
import sbtassembly.AssemblyPlugin.assemblySettings
import sbtassembly.MergeStrategy
import sbtdocker._
import sbtdocker.DockerKeys._
import sbtdocker.DockerSettings.baseDockerSettings
import scala.language.implicitConversions
import scalariform.formatter.preferences._
import scoverage.ScoverageKeys._
import scoverage.ScoverageSbtPlugin

/**
 * Base project configuration.
 */
class Base extends Build {
  val headVersion = "0.8.1"

  object Git {
    def git(arg: String, args: String*) = Process("git" +: arg +: args)
    val headRevision = git("rev-parse", "--short", "HEAD").!!.trim
    val version = git("name-rev", "--tags", "--name-only", headRevision).!!.trim match {
      case tag if tag == headVersion => tag
      case _ => s"$headVersion-SNAPSHOT"
    }
  }

  val developTwitterDeps = settingKey[Boolean]("use SNAPSHOT twitter dependencies")
  val doDevelopTwitterDeps = developTwitterDeps ?? false

  val baseSettings = Seq(
    organization := "io.buoyant",
    version := Git.version,
    homepage := Some(url("https://linkerd.io")),
    scalaVersion in GlobalScope := "2.11.7",
    ivyScala := ivyScala.value.map(_.copy(overrideScalaVersion = true)),
    scalacOptions ++= Seq("-Xfatal-warnings", "-deprecation", "-Ywarn-value-discard"),
    // XXX
    //conflictManager := ConflictManager.strict,
    resolvers ++= Seq(
      // com.twitter dependencies used to be hosted here:
      // "twitter-repo" at "https://maven.twttr.com",
      Resolver.mavenLocal,
      "typesafe" at "https://repo.typesafe.com/typesafe/releases"
    ),
    aggregate in assembly := false,
    developTwitterDeps := { sys.env.get("TWITTER_DEVELOP") == Some("1") },

    // Sonatype publishing
    publishArtifact in Test := false,
    pomIncludeRepository := { _ => false },
    publishMavenStyle := true,
    pomExtra :=
      <licenses>
        <license>
          <name>Apache License, Version 2.0</name>
          <url>http://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
      </licenses>
      <scm>
        <url><EMAIL>:BuoyantIO/linkerd.git</url>
        <connection>scm:git:<EMAIL>:BuoyantIO/linkerd.git</connection>
      </scm>
      <developers>
        <developer>
          <id>buoyant</id>
          <name>Buoyant Inc.</name>
          <url>https://buoyant.io/</url>
        </developer>
      </developers>,
    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")
    }
  )

  val aggregateSettings = Seq(
    publishArtifact := false
  )

  val scalariformSettings = baseScalariformSettings ++ Seq(
    ScalariformKeys.preferences := ScalariformKeys.preferences.value
      .setPreference(DoubleIndentClassDeclaration, false)
      .setPreference(PreserveSpaceBeforeArguments, false)
      .setPreference(SpacesAroundMultiImports,     false)
      .setPreference(SpacesWithinPatternBinders,   false)
  )

  val EndToEndTest =
    config("e2e") extend Test

  val IntegrationTest =
    config("integration") extend Test

  val defaultExecScript =
    """|#!/bin/sh
       |exec ${JAVA_HOME:-/usr}/bin/java -XX:+PrintCommandLineFlags $JVM_OPTIONS -server -jar $0 "$@"
       |""".stripMargin.split("\n").toSeq

  val dockerEnvPrefix = settingKey[String]("prefix to be applied to environment variables")
  val dockerJavaImage = settingKey[String]("base docker image, providing java")
  val dockerTag = settingKey[String]("docker image tag")
  val assemblyExecScript = settingKey[Seq[String]]("script used to execute the application")

  val appPackagingSettings = assemblySettings ++ baseDockerSettings ++ Seq(
    assemblyExecScript := defaultExecScript,
    assemblyOption in assembly := (assemblyOption in assembly).value.copy(
      prependShellScript = assemblyExecScript.value match {
        case Nil => None
        case script => Some(script)
      }),
    assemblyJarName in assembly := s"${name.value}-${version.value}-${configuration.value}-exec",
    assemblyMergeStrategy in assembly := {
      case "com/twitter/common/args/apt/cmdline.arg.info.txt.1" => MergeStrategy.discard
      case "META-INF/io.netty.versions.properties" => MergeStrategy.last
      case path => (assemblyMergeStrategy in assembly).value(path)
    },<commit_msg>Fix assembly packaging (#738)<commit_after>import com.typesafe.sbt.SbtScalariform.{scalariformSettings => baseScalariformSettings, _}
import sbt._
import sbt.Keys._
import complete.Parsers.spaceDelimited
import sbtassembly.AssemblyKeys._
import sbtassembly.AssemblyPlugin.assemblySettings
import sbtassembly.MergeStrategy
import sbtdocker._
import sbtdocker.DockerKeys._
import sbtdocker.DockerSettings.baseDockerSettings
import scala.language.implicitConversions
import scalariform.formatter.preferences._
import scoverage.ScoverageKeys._
import scoverage.ScoverageSbtPlugin

/**
 * Base project configuration.
 */
class Base extends Build {
  val headVersion = "0.8.1"

  object Git {
    def git(arg: String, args: String*) = Process("git" +: arg +: args)
    val headRevision = git("rev-parse", "--short", "HEAD").!!.trim
    val version = git("name-rev", "--tags", "--name-only", headRevision).!!.trim match {
      case tag if tag == headVersion => tag
      case _ => s"$headVersion-SNAPSHOT"
    }
  }

  val developTwitterDeps = settingKey[Boolean]("use SNAPSHOT twitter dependencies")
  val doDevelopTwitterDeps = (developTwitterDeps in Global) ?? false

  val baseSettings = Seq(
    organization := "io.buoyant",
    version := Git.version,
    homepage := Some(url("https://linkerd.io")),
    scalaVersion in GlobalScope := "2.11.7",
    ivyScala := ivyScala.value.map(_.copy(overrideScalaVersion = true)),
    scalacOptions ++=
      Seq("-Xfatal-warnings", "-deprecation", "-Ywarn-value-discard", "-feature"),
    // XXX
    //conflictManager := ConflictManager.strict,
    resolvers ++= Seq(
      "twitter-repo" at "https://maven.twttr.com",
      Resolver.mavenLocal,
      "typesafe" at "https://repo.typesafe.com/typesafe/releases"
    ),
    aggregate in assembly := false,
    (developTwitterDeps in Global) := { sys.env.get("TWITTER_DEVELOP") == Some("1") },

    // Sonatype publishing
    publishArtifact in Test := false,
    pomIncludeRepository := { _ => false },
    publishMavenStyle := true,
    pomExtra :=
      <licenses>
        <license>
          <name>Apache License, Version 2.0</name>
          <url>http://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
      </licenses>
      <scm>
        <url><EMAIL>:BuoyantIO/linkerd.git</url>
        <connection>scm:git:git@github.com:BuoyantIO/linkerd.git</connection>
      </scm>
      <developers>
        <developer>
          <id>buoyant</id>
          <name>Buoyant Inc.</name>
          <url>https://buoyant.io/</url>
        </developer>
      </developers>,
    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")
    }
  )

  val aggregateSettings = Seq(
    publishArtifact := false
  )

  val scalariformSettings = baseScalariformSettings ++ Seq(
    ScalariformKeys.preferences := ScalariformKeys.preferences.value
      .setPreference(DoubleIndentClassDeclaration, false)
      .setPreference(PreserveSpaceBeforeArguments, false)
      .setPreference(SpacesAroundMultiImports,     false)
      .setPreference(SpacesWithinPatternBinders,   false)
  )

  val EndToEndTest =
    config("e2e") extend Test

  val IntegrationTest =
    config("integration") extend Test

  val defaultExecScript =
    """|#!/bin/sh
       |exec ${JAVA_HOME:-/usr}/bin/java -XX:+PrintCommandLineFlags $JVM_OPTIONS -server -jar $0 "$@"
       |""".stripMargin.split("\n").toSeq

  val dockerEnvPrefix = settingKey[String]("prefix to be applied to environment variables")
  val dockerJavaImage = settingKey[String]("base docker image, providing java")
  val dockerTag = settingKey[String]("docker image tag")
  val assemblyExecScript = settingKey[Seq[String]]("script used to execute the application")

  val appPackagingSettings = assemblySettings ++ baseDockerSettings ++ Seq(
    assemblyExecScript := defaultExecScript,
    assemblyOption in assembly := (assemblyOption in assembly).value.copy(
      prependShellScript = assemblyExecScript.value match {
        case Nil => None
        case script => Some(script)
      }),
    assemblyJarName in assembly := s"${name.value}-${version.value}-${configuration.value}-exec",
    assemblyMergeStrategy in assembly := {
      case "BUILD" => MergeStrategy.discard
      case "com/twitter/common/args/apt/cmdline.arg.info.txt.1" => MergeStrategy.discard
      case "META-INF/io.netty.versions.properties" => MergeStrategy.last
      case path => (assemblyMergeStrategy in assembly).value(path)
    },
{'fraction_non_alphanumeric': 0.1317094201336495, 'fraction_numerical': 0.003772364733778832, 'mean_word_length': 3.486943907156673, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 75, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 1, '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': '1412360', 'n_tokens_mistral': 2919, 'n_tokens_neox': 2808, 'n_words': 572}