// The simplest possible sbt build file is just one line:

scalaVersion := "2.13.3"
// That is, to create a valid sbt build, all you've got to do is define the
// version of Scala you'd like your project to use.

// ============================================================================

// Lines like the above defining `scalaVersion` are called "settings". Settings
// are key/value pairs. In the case of `scalaVersion`, the key is "scalaVersion"
// and the value is "2.13.1"

// It's possible to define many kinds of settings, such as:

// Note, it's not required for you to define these three settings. These are
// mostly only necessary if you intend to publish your library's binaries on a
// place like Sonatype or Bintray.

// Want to use a published library in your project?
// You can define other libraries as dependencies in your build like this:

resolvers += "Jcenter" at "https://jcenter.bintray.com/"
resolvers += "JME Bintray" at "https://bintray.com/jmonkeyengine/com.jme3"
resolvers += "Jitpack" at "https://jitpack.io"

resolvers += Resolver.mavenLocal
resolvers += Resolver.sonatypeRepo("snapshots")

lazy val jmeVersion = "3.3.2-stable"

lazy val osName = System.getProperty("os.name") match {
  case n if n.startsWith("Linux")   => "linux"
  case n if n.startsWith("Mac")     => "mac"
  case n if n.startsWith("Windows") => "win"
  case _                            => throw new Exception("Unknown platform!")
}
lazy val javaFXModules =
  Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")

lazy val root = (project in file(".")).settings(
  inThisBuild(
    List(
      scalaVersion := scalaVersion.value, // 2.11.12, or 2.13.3
      semanticdbEnabled := true, // enable SemanticDB
      semanticdbVersion := "4.3.24" // use Scalafix compatible version
    )
  ),
  name := "mygame",
  organization := "wow.doge",
  version := "1.0-SNAPSHOT",
  libraryDependencies ++= Seq(
    // "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2",
// https://mvnrepository.com/artifact/org.jmonkeyengine/jme3-core
    "org.jmonkeyengine" % "jme3-core" % jmeVersion,
// https://mvnrepository.com/artifact/org.jmonkeyengine/jme3-desktop
    "org.jmonkeyengine" % "jme3-desktop" % jmeVersion,
// https://mvnrepository.com/artifact/org.jmonkeyengine/jme3-lwjgl3
    "org.jmonkeyengine" % "jme3-lwjgl3" % jmeVersion,
    "org.jmonkeyengine" % "jme3-effects" % jmeVersion,
    "org.jmonkeyengine" % "jme3-plugins" % jmeVersion,
    "org.jmonkeyengine" % "jme3-blender" % jmeVersion,
    "com.github.stephengold" % "Minie" % "3.0.0",
    "com.simsilica" % "zay-es" % "1.2.1",
    "org.typelevel" %% "cats-core" % "2.1.1",
    "com.lihaoyi" % "ammonite" % "2.2.0" cross CrossVersion.full,
    "org.jetbrains.kotlin" % "kotlin-main-kts" % "1.4.10",
    "org.jetbrains.kotlin" % "kotlin-scripting-jsr223" % "1.4.10",
    "org.codehaus.groovy" % "groovy-all" % "3.0.6" pomOnly (),
    "org.scalafx" %% "scalafx" % "14-R19",
    "com.typesafe.akka" %% "akka-actor-typed" % "2.6.10",
    "org.typelevel" %% "cats-core" % "2.1.1",
    "org.typelevel" %% "cats-effect" % "2.1.4",
    "io.monix" %% "monix" % "3.2.2",
    "io.monix" %% "monix-bio" % "1.1.0",
    "io.circe" %% "circe-core" % "0.13.0",
    "io.circe" %% "circe-generic" % "0.13.0",
    "com.softwaremill.sttp.client" %% "core" % "2.2.5",
    "com.softwaremill.sttp.client" %% "monix" % "2.2.5",
    "com.softwaremill.sttp.client" %% "circe" % "2.2.5",
    "com.softwaremill.sttp.client" %% "async-http-client-backend-monix" % "2.2.5",
    "com.github.valskalla" %% "odin-monix" % "0.8.1",
    "com.github.valskalla" %% "odin-json" % "0.9.1",
    "com.softwaremill.macwire" %% "util" % "2.3.7",
    "com.softwaremill.macwire" %% "macros" % "2.3.7" % "provided",
    // "com.softwaremill.macwire" %% "macrosakka" % "2.3.6" % "provided",
    "com.github.valskalla" %% "odin-slf4j" % "0.8.1",
    "com.softwaremill.quicklens" %% "quicklens" % "1.6.1",
    "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.0-RC1",
    "com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
    "io.circe" %% "circe-config" % "0.8.0",
    "com.beachape" %% "enumeratum-circe" % "1.6.1",
    "com.lihaoyi" %% "os-lib" % "0.7.1",
    // "com.jayfella" % "jme-jfx-11" % "1.1.5",
    // "com.github.goxr3plus" % "FX-BorderlessScene" % "4.4.0",
    // "com.github.Oshan96" % "CustomStage" % "v1.3.1",
    "com.badlogicgames.gdx" % "gdx-ai" % "1.8.2",
    "org.recast4j" % "recast" % "1.2.5",
    "org.recast4j" % "detour" % "1.2.5"
  ),
  // Determine OS version of JavaFX binaries

// Add JavaFX dependencies
  libraryDependencies ++= javaFXModules.map(m =>
    "org.openjfx" % s"javafx-$m" % "14.0.1" classifier osName
  ),
  scalacOptions ++= Seq(
    "-encoding",
    "UTF-8",
    "-deprecation",
    "-feature",
    "-language:existentials",
    "-language:experimental.macros",
    "-language:higherKinds",
    "-language:implicitConversions",
    "-unchecked",
    "-Xlint",
    "-Ywarn-numeric-widen",
    "-Ymacro-annotations",
    // "-Xlint:byname-implicit",
    // "utf-8", // Specify character encoding used by source files.
    //silence warnings for by-name implicits
    "-Wconf:cat=lint-byname-implicit:s",
    //give errors on non exhaustive matches
    "-Wconf:msg=match may not be exhaustive:e",
    "-explaintypes" // Explain type errors in more detail.
  ),
  javacOptions ++= Seq("-source", "11", "-target", "11"),
  javaOptions ++= Seq("-Xmx2G", "-Xms2G"),
  fork := true,
  assemblyMergeStrategy in assembly := {
    case PathList("javax", "servlet", xs @ _*)         => MergeStrategy.first
    case PathList(ps @ _*) if ps.last endsWith ".html" => MergeStrategy.first
    case "application.conf"                            => MergeStrategy.concat
    case "unwanted.txt"                                => MergeStrategy.discard
    case x if Assembly.isConfigFile(x) =>
      MergeStrategy.concat
    case PathList("META-INF", xs @ _*) =>
      (xs map { _.toLowerCase }) match {
        case ("manifest.mf" :: Nil) | ("index.list" :: Nil) |
            ("dependencies" :: Nil) =>
          MergeStrategy.discard
        case ps @ (x :: xs)
            if ps.last.endsWith(".sf") || ps.last.endsWith(".dsa") =>
          MergeStrategy.discard
        case "plexus" :: xs =>
          MergeStrategy.discard
        case "services" :: xs =>
          MergeStrategy.filterDistinctLines
        case ("spring.schemas" :: Nil) | ("spring.handlers" :: Nil) =>
          MergeStrategy.filterDistinctLines
        case _ => MergeStrategy.first // Changed deduplicate to first
      }
    case PathList(_*) => MergeStrategy.first
    // case x =>
    //   val oldStrategy = (assemblyMergeStrategy in assembly).value
    //   oldStrategy(x)
  }
  // scalaVersion := "2.13.2", // 2.11.12, or 2.13.3
  // semanticdbEnabled := true, // enable SemanticDB
  // semanticdbVersion := scalafixSemanticdb.revision // use Scalafix compatible version
  // semanticdbVersion := "4.3.24",
)
initialCommands in (console) := """ammonite.Main.main(Array.empty)"""

// Here, `libraryDependencies` is a set of dependencies, and by using `+=`,
// we're adding the scala-parser-combinators dependency to the set of dependencies
// that sbt will go and fetch when it starts up.
// Now, in any Scala file, you can import classes, objects, etc., from
// scala-parser-combinators with a regular import.

// TIP: To find the "dependency" that you need to add to the
// `libraryDependencies` set, which in the above example looks like this:

// "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"

// You can use Scaladex, an index of all known published Scala libraries. There,
// after you find the library you want, you can just copy/paste the dependency
// information that you need into your build file. For example, on the
// scala/scala-parser-combinators Scaladex page,
// https://index.scala-lang.org/scala/scala-parser-combinators, you can copy/paste
// the sbt dependency from the sbt box on the right-hand side of the screen.

// IMPORTANT NOTE: while build files look _kind of_ like regular Scala, it's
// important to note that syntax in *.sbt files doesn't always behave like
// regular Scala. For example, notice in this build file that it's not required
// to put our settings into an enclosing object or class. Always remember that
// sbt is a bit different, semantically, than vanilla Scala.

// ============================================================================

// Most moderately interesting Scala projects don't make use of the very simple
// build file style (called "bare style") used in this build.sbt file. Most
// intermediate Scala projects make use of so-called "multi-project" builds. A
// multi-project build makes it possible to have different folders which sbt can
// be configured differently for. That is, you may wish to have different
// dependencies or different testing frameworks defined for different parts of
// your codebase. Multi-project builds make this possible.

// Here's a quick glimpse of what a multi-project build looks like for this
// build, with only one "subproject" defined, called `root`:

// lazy val root = (project in file(".")).
//   settings(
//     inThisBuild(List(
//       organization := "ch.epfl.scala",
//       scalaVersion := "2.13.1"
//     )),
//     name := "hello-world"
//   )

// To learn more about multi-project builds, head over to the official sbt
// documentation at http://www.scala-sbt.org/documentation.html
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.4.3"
