<commit_before>import sbt._
import Keys._
import partest._
import SameTest._

object ScalaBuild extends Build with Layers {
  // New tasks/settings specific to the scala build.
  lazy val lockerLock: TaskKey[Unit] = TaskKey("locker-lock", 
    "Locks the locker layer of the compiler build such that it won't rebuild on changed source files.")
  lazy val lockerUnlock: TaskKey[Unit] = TaskKey("locker-unlock", 
    "Unlocks the locker layer of the compiler so that it will be recompiled on changed source files.")
  lazy val lockFile: SettingKey[File] = SettingKey("lock-file", 
    "Location of the lock file compiling this project.")
  // New tasks/settings specific to the scala build.
  lazy val lock: TaskKey[Unit] = TaskKey("lock", "Locks this project so it won't be recompiled.")
  lazy val unlock: TaskKey[Unit] = TaskKey("unlock", "Unlocks this project so it will be recompiled.")
  lazy val makeDist: TaskKey[File] = TaskKey("make-dist", 
    "Creates a mini-distribution (scala home directory) for this build in a zip file.")
  lazy val makeExplodedDist: TaskKey[File] = TaskKey("make-exploded-dist", 
    "Creates a mini-distribution (scala home directory) for this build in a directory.")
  lazy val makeDistMappings: TaskKey[Map[File, String]] = TaskKey("make-dist-mappings", 
    "Creates distribution mappings for creating zips,jars,directorys,etc.")
  lazy val buildFixed = AttributeKey[Boolean]("build-uri-fixed")

  // Build wide settings:
  override lazy val settings = super.settings ++ Versions.settings ++ Seq(
    autoScalaLibrary := false,
    resolvers += Resolver.url(
      "Typesafe nightlies", 
      url("https://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/")
    )(Resolver.ivyStylePatterns),
    resolvers ++= Seq(
      "junit interface repo" at "https://repository.jboss.org/nexus/content/repositories/scala-tools-releases",
      ScalaToolsSnapshots
    ),
    organization := "org.scala-lang",
    version <<= Versions.mavenVersion,
    pomExtra := <xml:group>
      <inceptionYear>2002</inceptionYear>
        <licenses>
          <license>
            <name>BSD-like</name>
            <url>http://www.scala-lang.org/downloads/license.html</url>
          </license>
        </licenses>
        <scm>
          <connection>scm:git:git://github.com/scala/scala.git</connection>
        </scm>
        <issueManagement>
          <system>jira</system>
          <url>http://issues.scala-lang.org</url>
        </issueManagement>
      </xml:group>,
    commands += Command.command("fix-uri-projects") { (state: State) =>
      if(state.get(buildFixed) getOrElse false) state
      else {
        // TODO -fix up scalacheck's dependencies!
        val extracted = Project.extract(state)
        import extracted._
        def fix(s: Setting[_]): Setting[_] = s match {
          case ScopedExternalSetting(`scalacheck`, scalaInstance.key, setting)    => fullQuickScalaReference mapKey Project.mapScope(_ => s.key.scope)
          case s                                                                  => s
         }
         val transformed = session.mergeSettings map ( s => fix(s) )
         val scopes = transformed collect { case ScopedExternalSetting(`scalacheck`, _, s) => s.key.scope } toSet
         // Create some fixers so we don't download scala or rely on it.
         val fixers = for { scope <- scopes
                            setting <- Seq(autoScalaLibrary := false, crossPaths := false)
                      } yield setting mapKey Project.mapScope(_ => scope)
         val newStructure = Load.reapply(transformed ++ fixers, structure)
         Project.setProject(session, newStructure, state).put(buildFixed, true)
      }
    },
    onLoad in Global <<= (onLoad in Global) apply (_ andThen { (state: State) =>
      "fix-uri-projects" :: state
    })
  )

  // Collections of projects to run 'compile' on.
  lazy val compiledProjects = Seq(quickLib, quickComp, continuationsLibrary, actors, swing, forkjoin, fjbg)
  // Collection of projects to 'package' and 'publish' together.
  lazy val packagedBinaryProjects = Seq(scalaLibrary, scalaCompiler, swing, continuationsPlugin, jline, scalap)
  lazy val partestRunProjects = Seq(testsuite, continuationsTestsuite)
  
  private def epflPomExtra = (
    <xml:group>
      <inceptionYear>2002</inceptionYear>
      <licenses>
        <license>
          <name>BSD-like</name>
          <url>http://www.scala-lang.org/downloads/license.html</url>
        </license>
      </licenses>
      <scm>
        <connection>scm:git:git://github.com/scala/scala.git</connection>
      </scm>
      <issueManagement>
        <system>jira</system>
        <url>http://issues.scala-lang.org</url>
      </issueManagement>
    </xml:group>
  )
    
  // Settings used to make sure publishing goes smoothly.
  def publishSettings: Seq[Setting[_]] = Seq(
    ivyScala ~= ((is: Option[IvyScala]) => is.map(_.copy(checkExplicit = false))),
    pomIncludeRepository := (_ => false),
    publishMavenStyle := true,
    makePomConfiguration <<= makePomConfiguration apply (_.copy(configurations = Some(Seq(Compile, Default)))),
    pomExtra := epflPomExtra
  )

  // Settings for root project.  These are aggregate tasks against the rest of the build.
  def projectSettings: Seq[Setting[_]] = publishSettings ++ Seq(
    doc in Compile <<= (doc in documentation in Compile).identity,
    // These next two aggregate commands on several projects and return results that are to be ignored by remaining tasks.
    compile in Compile <<= compiledProjects.map(p => compile in p in Compile).join.map(_.head),
    // TODO - just clean target? i.e. target map IO.deleteRecursively
    clean <<= (compiledProjects ++ partestRunProjects).map(p => clean in p).dependOn,
    packageBin in Compile <<= packagedBinaryProjects.map(p => packageBin in p in Compile).join.map(_.head),
    // TODO - Make sure scalaLibrary has packageDoc + packageSrc from documentation attached...
    publish <<= packagedBinaryProjects.map(p => publish in p).join.map(_.head),
    publishLocal <<= packagedBinaryProjects.map(p => publishLocal in p).join.map(_.head),
    packageDoc in Compile <<= (packageDoc in documentation in Compile).identity,
    packageSrc in Compile <<= (packageSrc in documentation in Compile).identity,
    test in Test <<= (runPartest in testsuite, runPartest in continuationsTestsuite, checkSame in testsuite) map { (a,b,c) => () },
    lockerLock <<= (lockFile in lockerLib, lockFile in lockerComp, compile in Compile in lockerLib, compile in Compile in lockerComp) map { (lib, comp, _, _) =>
      Seq(lib,comp).foreach(f => IO.touch(f))
    },
    lockerUnlock <<= (lockFile in lockerLib, lockFile in lockerComp) map { (lib, comp) =>
      Seq(lib,comp).foreach(IO.delete)
    },
    genBinQuick <<= (genBinQuick in scaladist).identity,
    makeDist <<= (makeDist in scaladist).identity,
    makeExplodedDist <<= (makeExplodedDist in scaladist).identity,
    // Note: We override unmanagedSources so that ~ compile will look at all these sources, then run our aggregated compile...
    unmanagedSourceDirectories in Compile <<= baseDirectory apply (_ / "src") apply { dir =>
      Seq("library/scala","actors","compiler","fjbg","swing","continuations/library","forkjoin") map (dir / _)
    },
    // TODO - Make exported products == makeDist so we can use this when creating a *real* distribution.
    commands += Release.pushStarr
    //commands += Release.setStarrHome
  )
  // Note: Root project is determined by lowest-alphabetical project that has baseDirectory as file(".").  we use aaa_ to 'win'.
  lazy val aaa_root = Project("scala", file(".")) settings(projectSettings: _*) settings(ShaResolve.settings: _*)

  // External dependencies used for various projects
  lazy val externalDeps: Setting[_] = libraryDependencies <<= (sbtVersion)(v => 
    Seq(
      "org.apache.ant" % "ant" % "1.8.2",
      "org.scala-sbt" % "compiler-interface" % v % "provided"
    )
  )

  // These are setting overrides for most artifacts in the Scala build file.
  def settingOverrides: Seq[Setting[_]] = publishSettings ++ Seq(
                             crossPaths := false,
                             autoScalaLibrary := false,
                             publishArtifact in packageDoc := false,
                             publishArtifact in packageSrc := false,
                             target <<= (baseDirectory, name) apply (_ / "target" / _),
                             (classDirectory in Compile) <<= target(_ / "classes"),
                             javacOptions ++= Seq("-target", "1.5", "-source", "1.5"),
                             scalaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _),
                             javaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _),
                             autoScalaLibrary := false,
                             unmanagedJars in Compile := Seq(),
                             // Most libs in the compiler use this order to build.
                             compileOrder in Compile := CompileOrder.JavaThenScala,
                             lockFile <<= target(_ / "compile.lock"),
                             skip in Compile <<= lockFile.map(_  exists),
                             lock <<= lockFile map { f => IO.touch(f) },
                             unlock <<= lockFile map IO.delete
                            )

  // --------------------------------------------------------------
  //  Libraries used by Scalac that change infrequently
  //  (or hopefully so).
  // --------------------------------------------------------------
<commit_msg>Fixed issue where forkjoin analysis bombed with incompatible class change exception.<commit_after>import sbt._
import Keys._
import partest._
import SameTest._

object ScalaBuild extends Build with Layers {
  // New tasks/settings specific to the scala build.
  lazy val lockerLock: TaskKey[Unit] = TaskKey("locker-lock", 
    "Locks the locker layer of the compiler build such that it won't rebuild on changed source files.")
  lazy val lockerUnlock: TaskKey[Unit] = TaskKey("locker-unlock", 
    "Unlocks the locker layer of the compiler so that it will be recompiled on changed source files.")
  lazy val lockFile: SettingKey[File] = SettingKey("lock-file", 
    "Location of the lock file compiling this project.")
  // New tasks/settings specific to the scala build.
  lazy val lock: TaskKey[Unit] = TaskKey("lock", "Locks this project so it won't be recompiled.")
  lazy val unlock: TaskKey[Unit] = TaskKey("unlock", "Unlocks this project so it will be recompiled.")
  lazy val makeDist: TaskKey[File] = TaskKey("make-dist", 
    "Creates a mini-distribution (scala home directory) for this build in a zip file.")
  lazy val makeExplodedDist: TaskKey[File] = TaskKey("make-exploded-dist", 
    "Creates a mini-distribution (scala home directory) for this build in a directory.")
  lazy val makeDistMappings: TaskKey[Map[File, String]] = TaskKey("make-dist-mappings", 
    "Creates distribution mappings for creating zips,jars,directorys,etc.")
  lazy val buildFixed = AttributeKey[Boolean]("build-uri-fixed")

  // Build wide settings:
  override lazy val settings = super.settings ++ Versions.settings ++ Seq(
    autoScalaLibrary := false,
    resolvers += Resolver.url(
      "Typesafe nightlies", 
      url("https://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/")
    )(Resolver.ivyStylePatterns),
    resolvers ++= Seq(
      "junit interface repo" at "https://repository.jboss.org/nexus/content/repositories/scala-tools-releases",
      ScalaToolsSnapshots
    ),
    organization := "org.scala-lang",
    version <<= Versions.mavenVersion,
    pomExtra := <xml:group>
      <inceptionYear>2002</inceptionYear>
        <licenses>
          <license>
            <name>BSD-like</name>
            <url>http://www.scala-lang.org/downloads/license.html</url>
          </license>
        </licenses>
        <scm>
          <connection>scm:git:git://github.com/scala/scala.git</connection>
        </scm>
        <issueManagement>
          <system>jira</system>
          <url>http://issues.scala-lang.org</url>
        </issueManagement>
      </xml:group>,
    commands += Command.command("fix-uri-projects") { (state: State) =>
      if(state.get(buildFixed) getOrElse false) state
      else {
        // TODO -fix up scalacheck's dependencies!
        val extracted = Project.extract(state)
        import extracted._
        def fix(s: Setting[_]): Setting[_] = s match {
          case ScopedExternalSetting(`scalacheck`, scalaInstance.key, setting)    => fullQuickScalaReference mapKey Project.mapScope(_ => s.key.scope)
          case s                                                                  => s
         }
         val transformed = session.mergeSettings map ( s => fix(s) )
         val scopes = transformed collect { case ScopedExternalSetting(`scalacheck`, _, s) => s.key.scope } toSet
         // Create some fixers so we don't download scala or rely on it.
         val fixers = for { scope <- scopes
                            setting <- Seq(autoScalaLibrary := false, crossPaths := false)
                      } yield setting mapKey Project.mapScope(_ => scope)
         val newStructure = Load.reapply(transformed ++ fixers, structure)
         Project.setProject(session, newStructure, state).put(buildFixed, true)
      }
    },
    onLoad in Global <<= (onLoad in Global) apply (_ andThen { (state: State) =>
      "fix-uri-projects" :: state
    })
  )

  // Collections of projects to run 'compile' on.
  lazy val compiledProjects = Seq(quickLib, quickComp, continuationsLibrary, actors, swing, forkjoin, fjbg)
  // Collection of projects to 'package' and 'publish' together.
  lazy val packagedBinaryProjects = Seq(scalaLibrary, scalaCompiler, swing, continuationsPlugin, jline, scalap)
  lazy val partestRunProjects = Seq(testsuite, continuationsTestsuite)
  
  private def epflPomExtra = (
    <xml:group>
      <inceptionYear>2002</inceptionYear>
      <licenses>
        <license>
          <name>BSD-like</name>
          <url>http://www.scala-lang.org/downloads/license.html</url>
        </license>
      </licenses>
      <scm>
        <connection>scm:git:git://github.com/scala/scala.git</connection>
      </scm>
      <issueManagement>
        <system>jira</system>
        <url>http://issues.scala-lang.org</url>
      </issueManagement>
    </xml:group>
  )
    
  // Settings used to make sure publishing goes smoothly.
  def publishSettings: Seq[Setting[_]] = Seq(
    ivyScala ~= ((is: Option[IvyScala]) => is.map(_.copy(checkExplicit = false))),
    pomIncludeRepository := (_ => false),
    publishMavenStyle := true,
    makePomConfiguration <<= makePomConfiguration apply (_.copy(configurations = Some(Seq(Compile, Default)))),
    pomExtra := epflPomExtra
  )

  // Settings for root project.  These are aggregate tasks against the rest of the build.
  def projectSettings: Seq[Setting[_]] = publishSettings ++ Seq(
    doc in Compile <<= (doc in documentation in Compile).identity,
    // These next two aggregate commands on several projects and return results that are to be ignored by remaining tasks.
    compile in Compile <<= compiledProjects.map(p => compile in p in Compile).join.map(_.head),
    // TODO - just clean target? i.e. target map IO.deleteRecursively
    clean <<= (compiledProjects ++ partestRunProjects).map(p => clean in p).dependOn,
    packageBin in Compile <<= packagedBinaryProjects.map(p => packageBin in p in Compile).join.map(_.head),
    // TODO - Make sure scalaLibrary has packageDoc + packageSrc from documentation attached...
    publish <<= packagedBinaryProjects.map(p => publish in p).join.map(_.head),
    publishLocal <<= packagedBinaryProjects.map(p => publishLocal in p).join.map(_.head),
    packageDoc in Compile <<= (packageDoc in documentation in Compile).identity,
    packageSrc in Compile <<= (packageSrc in documentation in Compile).identity,
    test in Test <<= (runPartest in testsuite, runPartest in continuationsTestsuite, checkSame in testsuite) map { (a,b,c) => () },
    lockerLock <<= (lockFile in lockerLib, lockFile in lockerComp, compile in Compile in lockerLib, compile in Compile in lockerComp) map { (lib, comp, _, _) =>
      Seq(lib,comp).foreach(f => IO.touch(f))
    },
    lockerUnlock <<= (lockFile in lockerLib, lockFile in lockerComp) map { (lib, comp) =>
      Seq(lib,comp).foreach(IO.delete)
    },
    genBinQuick <<= (genBinQuick in scaladist).identity,
    makeDist <<= (makeDist in scaladist).identity,
    makeExplodedDist <<= (makeExplodedDist in scaladist).identity,
    // Note: We override unmanagedSources so that ~ compile will look at all these sources, then run our aggregated compile...
    unmanagedSourceDirectories in Compile <<= baseDirectory apply (_ / "src") apply { dir =>
      Seq("library/scala","actors","compiler","fjbg","swing","continuations/library","forkjoin") map (dir / _)
    },
    // TODO - Make exported products == makeDist so we can use this when creating a *real* distribution.
    commands += Release.pushStarr
    //commands += Release.setStarrHome
  )
  // Note: Root project is determined by lowest-alphabetical project that has baseDirectory as file(".").  we use aaa_ to 'win'.
  lazy val aaa_root = Project("scala", file(".")) settings(projectSettings: _*) settings(ShaResolve.settings: _*)

  // External dependencies used for various projects
  lazy val externalDeps: Setting[_] = libraryDependencies <<= (sbtVersion)(v => 
    Seq(
      "org.apache.ant" % "ant" % "1.8.2",
      "org.scala-sbt" % "compiler-interface" % v % "provided"
    )
  )

  // These are setting overrides for most artifacts in the Scala build file.
  def settingOverrides: Seq[Setting[_]] = publishSettings ++ Seq(
                             crossPaths := false,
                             autoScalaLibrary := false,
                             // Work around a bug where scala-library (and forkjoin) is put on classpath for analysis.
                             classpathOptions := ClasspathOptions.manual,
                             publishArtifact in packageDoc := false,
                             publishArtifact in packageSrc := false,
                             target <<= (baseDirectory, name) apply (_ / "target" / _),
                             (classDirectory in Compile) <<= target(_ / "classes"),
                             javacOptions ++= Seq("-target", "1.5", "-source", "1.5"),
                             scalaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _),
                             javaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _),
                             autoScalaLibrary := false,
                             unmanagedJars in Compile := Seq(),
                             // Most libs in the compiler use this order to build.
                             compileOrder in Compile := CompileOrder.JavaThenScala,
                             lockFile <<= target(_ / "compile.lock"),
                             skip in Compile <<= lockFile map (_.exists),
                             lock <<= lockFile map (f => IO.touch(f)),
                             unlock <<= lockFile map IO.delete
                            )

  // --------------------------------------------------------------
  //  Libraries used by Scalac that change infrequently
  //  (or hopefully so).
  // --------------------------------------------------------------

{'fraction_non_alphanumeric': 0.12826153688734268, 'fraction_numerical': 0.0015348408881612607, 'mean_word_length': 2.5024189213402614, 'pattern_counts': {'":': 0, '<': 203, '<?xml version=': 0, '>': 135, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '467992', 'n_tokens_mistral': 5508, 'n_tokens_neox': 5343, 'n_words': 1559}