aboutsummaryrefslogtreecommitdiff
path: root/build.sbt
blob: c1a5c592524989a59209b29681216691d0c8bda3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import scala.sys.process._

val scalaVersions = Seq("2.13.1", "2.12.10", "2.11.12")
val macrosParadiseVersion = "2.1.1"

// version is derived from latest git tag
version in ThisBuild := ("git describe --always --dirty=-SNAPSHOT --match v[0-9].*" !!).tail.trim
organization in ThisBuild := "ch.jodersky"
scalacOptions in ThisBuild ++= Seq(
  "-deprecation",
  "-feature",
  "-Xfatal-warnings",
  "-Xlint"
)
licenses in ThisBuild := Seq(("BSD New", url("http://opensource.org/licenses/BSD-3-Clause")))

lazy val root = (project in file("."))
  .aggregate(macros, plugin)
  .settings(
    publish := {},
    publishLocal := {},
    // make sbt-pgp happy
    publishTo := Some(Resolver.file("Unused transient repository", target.value / "unusedrepo")),
    addCommandAlias("test-plugin", ";+macros/publishLocal;scripted")
  )

lazy val macros = (project in file("macros"))
  .disablePlugins(ScriptedPlugin)
  .settings(
    name := "sbt-jni-macros",
    crossScalaVersions := scalaVersions,
    libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided,
    libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,

    libraryDependencies ++= {
      CrossVersion.partialVersion(scalaVersion.value) match {
        case Some((2, n)) if n >= 13 => Seq()
        case _ => Seq(
          compilerPlugin("org.scalamacros" % "paradise" % macrosParadiseVersion cross CrossVersion.full)
        )
      }
    },
    Compile / scalacOptions ++= {
      CrossVersion.partialVersion(scalaVersion.value) match {
        case Some((2, n)) if n >= 13 => Seq("-Ymacro-annotations")
        case _ => Seq()
      }
    }
  )

lazy val plugin = (project in file("plugin"))
  .enablePlugins(SbtPlugin)
  .settings(
    name := "sbt-jni",
    publishMavenStyle := false,
    libraryDependencies += "org.ow2.asm" % "asm" % "6.2.1",
    // make project settings available to source
    sourceGenerators in Compile += Def.task {
      val src = s"""|/* Generated by sbt */
                    |package ch.jodersky.sbt.jni
                    |
                    |private[jni] object ProjectVersion {
                    |  final val MacrosParadise = "${macrosParadiseVersion}"
                    |  final val Macros = "${version.value}"
                    |}
                    |""".stripMargin
      val file = sourceManaged.value / "ch" / "jodersky" / "sbt" / "jni" / "ProjectVersion.scala"
      IO.write(file, src)
      Seq(file)
    }.taskValue,
    scriptedLaunchOpts := Seq(
      "-Dplugin.version=" + version.value,
      "-Xmx2g", "-Xss2m"
    )
  )